File.read()

Availability

Flash Media Server 2.

Usage

fileObject.read(numChars)

Parameters

numChars An integer specifying the number of characters to read. If numChars specifies more bytes than are left in the file, the method reads to the end of the file.

Returns

A string.

Description

Method; reads the specified number of characters from a file and returns a string. The operation will fail if the file is opened in binary mode.

Example

The following code opens a text file in read mode and sets variables for the first 100 characters, a line, and a byte:

if (myFileObject.open( "text", "read") ){
    strVal = myFileObject.read(100);
    strLine = myFileObject.readln();
    strChar = myFileObject.readByte();
} 

See also

File.readAll(), File.readByte(), File.readln()