Class PushbackInputStream
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 directly 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
.
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
UInt8
s. pushback (v :
)ListView<Int8> - Pushes back a list of
Int8
s. pushback (c :
)Char8 - Pushes back a single
Char8
. pushback (c :
)ListView<Char8> - Pushes back a list of
Char
s. pushback (s :
)String - Pushes back a
String
.
close():Error?
lines():Iterator<String>
sendTo(OutputStream):Maybe<Int>
readLine():String?
readFully():Array<UInt8>
readFully():String
read(Pointer<Char8>, Int):Int
read(Pointer<Int8>, Int):Int
read(Pointer<UInt8>, Int):Int
read():Char8?
read():Int64?
read():Int32?
read():Int16?
read():Int8?
read():UInt64?
read():UInt32?
read():UInt16?
Initializers
init
(source :InputStream
)
Creates a new PushbackInputStream
.
- Parameters:
-
- value of typesource 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 UInt8
s.
- Parameters:
-
-v the array to push
method pushback
(v :ListView<Int8>
)
Pushes back a list of Int8
s.
- 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 Char
s.
- Parameters:
-
-c the array to push
method pushback
(s :String
)
Pushes back a String
.
- Parameters:
-
-s the string to push