Typical use is to use the Reader factory function to instantiate an object of an appropriate derived class based on the file extension of the given path:

let reader <- Reader(path);


The whole contents of the file can then be read into a buffer with:

let buffer <- reader.scan();


Finally, close the file:

reader.close();


Name Description

### Member Functions

Name Description
open Open a file.
scan Read the entire contents of the file.
walk Start reading the contents of the file sequentially, if the root element is a sequence.
hasNext When reading the contents of the file sequentially, is there another element?
next When reading the contents of the file sequentially, get the next element.
close Close the file.

### Factory Function Details

Create a reader for a file.

• path: Path of the file.

The file extension of path is used to determine the precise type of the returned object. Supported file extension are .json and .yml.

### Member Function Details

#### close

abstract function close()

Close the file.

#### hasNext

abstract function hasNext() -> Boolean

When reading the contents of the file sequentially, is there another element?

See also: walk(), next().

#### next

abstract function next() -> Buffer

When reading the contents of the file sequentially, get the next element.

#### open

abstract function open(path:String)

Open a file.

• path: Path of the file.

#### scan

abstract function scan() -> Buffer

Read the entire contents of the file.

• buffer: Buffer into which to read.

#### walk

abstract function walk()

Start reading the contents of the file sequentially, if the root element is a sequence. This avoids reading the entire file into memory at once.

The call should be followed by alternating calls to hasNext() and next() to read each element of the sequence, e.g.:

reader.walk();

See also: hasNext(), next().