paranoiacblack/Obfuscated-OS — comment on commit aee193f26a8723cab7e90b09404c47675da74e15
File: nachos/userprog/UserProcess.java line 406
By paranoiacblack:

So two things. If the file descriptor is 0, 1, or 2 it corresponds to stdin, stdout, or stderr, respectively. Secondly, to extract from the buffer, what you'll probably want to do is reference my code in the handleClose function. On line 404, you say int fileDescriptor = readVirtualMemory(...), but the return of readVirtualMemory(...) is the amount of bytes read from virtual memory. You'll need to convert the data from your byte arrays into integers.

Anyways, that aside, you need to get the fileDescriptor and the count first. Then you'll probably want to open up a BufferedReader and at most count characters into a string. Then write that string into the buffer using writeVirtualMemoryString.