File.read()

NES2+Syntax

							file.read(num)

Description

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.

Example

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.

Listing 8.82 Using the read() Method
 <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 ...

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.