August 1999
Intermediate to advanced
1488 pages
72h 53m
English
file.eof()
The eof() method of the File object returns true if the position of the pointer within the file is past the end of the file. It returns false otherwise.
Listing 8.74 reads a file and writes its contents to the page until the end of the file is found with the eof() method.
<SERVER>
// Open a log file for reading
var myLog = new File("/data/logs/today.log");
myLog.open("r");
// Write the contents of the log file to the page
while (!myLog.eof()){
myBytes = File.byteToString(myLog.readByte());
write(myBytes);
}
// Close the file
myLog.close();
</SERVER>
|
Read now
Unlock full access