Libraries anvil io InputStream

class InputStream
extends anvil.lang.object
Datatype representing an input stream of bytes.

Methods

int available()
Returns number of bytes available from this stream without blocking.
Throws IOError -  If an I/O error occurs.

void close()
Closes this input stream and releases any system resources associated with the stream.
Throws IOError -  If an I/O error occurs.

int getColumnNumber()
Gets the current column number of this stream. Useful only with text content.

int getLineNumber()
Gets the current line number of this stream. Useful only with text content.

int read()
Reads a single byte from stream.
string read(int maxBytes)
Reads upto given amount of bytes from stream.
Reads bytes from stream.
Returns Byte read, or bytes read as string, or null if end of stream has been reached.
Throws IOError -  If an I/O error occurs.

int readBinary(binary bin)
int readBinary(binary bin, int offset, int length)
Reads bytes from stream.
Parameters array -  The binary into which the data is written
offset -  The start offset in binary
length -  The maximum number of bytes to read.
Returns Number of bytes read, or -1 if end of stream has been reached.
Throws IOError -  If an I/O error occurs.

object readData()
Reads serialized data from this stream.
Returns Unserialized data
Throws IOError -  If an I/O error occurs.
CorruptedSerialization -  If serialized data is corrupted

string readLine()
Reads single line from stream.
Returns Line read or, null if end of stream was reached.
Throws IOError -  If an I/O error occurs.

list readLines()
Reads all available lines from stream
list readLines(int maxLines)
Reads upto given amount of lines from stream.
Parameters maxLinex -  Maximum number of lines to return
Returns Lines read as list of strings with linefeeds stripped.
Throws IOError -  If an I/O error occurs.

int skip(int amount)
Skips over some bytes in this stream.
Parameters amount -  Amount of bytes to skip
Returns Amount of bytes skipped, or -1 if end of stream was reached before any bytes were skipped.
Throws IOError -  If an I/O error occurs.

int writeTo(OutputStream output)
Writes the contents of this stream to given OutputStream.
Returns Amount of bytes written
Throws IOError -  If an I/O error occurs.


Operators

Returns iterator (of strings) that will read the stream line-by-line.