This is the documentation for the development version. There are no official binaries for it; build it from the source code in git. Download links on these pages work only after the release. For the current release, see version 7.0.

FILE

Class that represents file on file system. On the server, available only if NXSL.EnableFileIOFunctions server configuration variable is turned on (change requires server restart). Use IO::OpenFile() function to create a new FILE object.

A script that runs on behalf of a user (see Scripts Started by a User) also needs the "Access server file system from scripts" system access right to open a file, and scripts in read-only script contexts cannot open files while Scripts.RestrictWriteAccess is enabled. In both cases IO::OpenFile() returns null.

File read and write position in the file depends on mode file was opened in.

Instance attributes

eof: bool

true if end of file was reached or the file is closed, false otherwise.

name: String

File name

Instance methods

close(): void

Close file

read(numberOfSymbols): String

Read provided number of bytes from file.

Table 1. Parameters

numberOfSymbols

Integer

Number of symbol to read from file

Return

String with symbols read from file (empty string if numberOfSymbols is zero or negative), or null if file closed or end of file reached.

readLine(): String

Read line from file.

Return

String with read line from file (without the trailing newline character), or null if file closed or end of file reached. Lines longer than 8191 characters are returned in parts.

write(text): void

Will write provided text to the file.

Table 2. Parameters

text

String

Text to write in to the file

writeLine(text): void

Will write provided text to the file and will add new line at the end.

Table 3. Parameters

text

String

Text to write in to the file