abstract class Reader < Iterator<Buffer>
Read data from a file.
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
let reader <- make_reader(path);
The whole contents of the file can be read at once with:
let buffer <- reader.slurp();
Alternatively, where the root element of the file is an array, the contents
may be read sequentially, one element at a time, using the
Iterator interface, from which
Finally, close the file:
|open||Open a file.|
|slurp||Read the whole contents of the file into a buffer.|
|close||Close the file.|
Member Function Details
abstract function close()
Close the file.
abstract function open(path:String)
Open a file.
- path: Path of the file.
abstract function slurp() -> Buffer
Read the whole contents of the file into a buffer.
Returns: Buffer with the file contents.