File.getPosition()
NES2+Syntax
file.getPosition()
Description
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.
Example
Listing 8.79 loops through each character, printing it on a new line next to its indexed location.
Listing 8.79 Using the getPosition() Method
<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 ... |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.