August 1999
Intermediate to advanced
1488 pages
72h 53m
English
file.getPosition()
The getPosition() method of the File object returns the zero-based index position of the current pointer in the file. If the pointer is on the first character, 0 is returned. If there is an error, -1 is returned.
Listing 8.79 loops through each character, printing it on a new line next to its indexed location.
<SERVER> // Open the files var myLog = new File("/data/logs/today.log"); var mySummary = new File("/data/logs/summary.log"); myLog.open("r"); mySummary.open("w"); // Write the contents of the log file to the page for(var i = 0; i <= myLog.getLength(); i++){ myBytes = File.byteToString(myLog.readByte()); mySummary.write('Character ... |
Read now
Unlock full access