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