August 1999
Intermediate to advanced
1488 pages
72h 53m
English
file.readByte(num)
The readByte() method of the File object starts at the current pointer in the file and reads num bytes in the file. If you try to read bytes past the end of the file, the method will read all of the bytes and stop. Use the read() method if you are trying to read the characters in text data.
Listing 8.83 reads information from a text file and writes every other byte to the user's page. The setPosition() method is used to move the pointer correctly, and the readByte() method is used to read the data.
<SERVER> // Open the files var myLog = new File("/data/logs/today.dat"); myLog.open("rb"); // Write some characters to the page for(var ... |
Read now
Unlock full access