frost.io

Class PushbackInputStream

    └ InputStream
         └ Object

An input stream which allows data to be "pushed back" into it, so that it may be read again. This is useful in situations such as parsing, in which you may wish to read until you encounter a delimiter and then push the delimiter back into the stream so that it can be handled by other code.

The PushbackInputStream "sits on top of" another stream, reading from it when it requires new data. You should not read directly from the underlying stream while reading from a PushbackInputStream. Closing the PushbackInputStream does not close the underlying stream, but if the PushbackInputStream holds the only remaining reference to the underlying stream, then discarding the PushbackInputStream will cause the underlying stream to likewise be discarded and thus closed.

Source Code:
View Source

Initializer Summary

init(source:InputStream)
Creates a new PushbackInputStream.
Inherited Fields:

Instance Method Summary

read():UInt8?
Reads and returns a single byte.
pushback(v:UInt8)
Pushes back a single UInt8, so that it will be the next byte read by the stream.
pushback(v:Int8)
Pushes back a single Int8, so that it will be the next byte read by the stream.
pushback(v:ListView<UInt8>)
Pushes back a list of UInt8s.
pushback(v:ListView<Int8>)
Pushes back a list of Int8s.
pushback(c:Char8)
Pushes back a single Char8.
pushback(c:ListView<Char8>)
Pushes back a list of Chars.
pushback(s:String)
Pushes back a String.
Inherited Methods:

Initializers

init (source:InputStream)

Creates a new PushbackInputStream.

Parameters:
source - value of type InputStream

Instance Methods

@override
method read ():UInt8?

Reads and returns a single byte. Blocks until at least one byte is available for reading, or returns null if the end of the stream has been reached or in the event of an error.

Overrides:
frost.io.InputStream.read
method pushback (v:UInt8)

Pushes back a single UInt8, so that it will be the next byte read by the stream.

Parameters:
v - the UInt8 to push
method pushback (v:Int8)

Pushes back a single Int8, so that it will be the next byte read by the stream.

Parameters:
v - the Int8 to push
method pushback (v:ListView<UInt8>)

Pushes back a list of UInt8s.

Parameters:
v - the array to push
method pushback (v:ListView<Int8>)

Pushes back a list of Int8s.

Parameters:
v - the array to push
method pushback (c:Char8)

Pushes back a single Char8.

Parameters:
c - the character to push
method pushback (c:ListView<Char8>)

Pushes back a list of Chars.

Parameters:
c - the array to push
method pushback (s:String)

Pushes back a String.

Parameters:
s - the string to push