File(filename, mode)

new File(filename, mode)

Open a file, for file modes see FILE. Files can only either be read or written, never both.Writing to a closed file throws an exception.
Parameters:
Name Type Description
filename string the name of the file.
mode string READ, WRITE or APPEND.

Methods

Close()

Close the file.

ReadByte() → {number}

Read a single byte from file and return it as number.
Returns:
number - the byte as a number or null for EOF.

ReadLine() → {string}

Read a line of text from file. The maximum line length is 4096 byte.
Returns:
string - the next line or null for EOF.

WriteByte()

Write a single byte to a file.

WriteLine(txt)

Write a NEWLINE terminated string to a file.
Parameters:
Name Type Description
txt string the string to write.

WriteString(txt)

Write a string to a file.
Parameters:
Name Type Description
txt string the string to write.