Standard Library
class FileInStream
A stream that reads text from a file descriptor.
since 0.1.0-alpha.1linux
Overview
Get one from File.reader(), or wrap a descriptor yourself (0 is standard input). pull reads one line and read reads a number of bytes.
Examples
Reading lines from a file
using File file = File("notes.txt", std::read);
FileInStream input = file.reader();
string line = input.pull();
while (line != "") {
console.writeln(line);
line = input.pull();
}
not run — reads a file
Constructors
new
new(int f)Creates a stream that reads from a file descriptor.
Parameters
- f
- The descriptor to read from.
Methods
pull
pull() -> stringReads one line, without its line ending.
Returns
The next line, or "" at the end of the input. An empty line in the middle of the input also gives "".
read
read(int max) -> stringReads up to a number of bytes.
Parameters
- max
- The most bytes to read.
Returns
The text read; "" at the end of the input.
See also
- reader — Returns a stream that reads from this file.
- FileOutStream — A stream that writes text to a file descriptor.