PushbackInputStream
public
class
PushbackInputStream
extends FilterInputStream
| java.lang.Object | |||
| ↳ | java.io.InputStream | ||
| ↳ | java.io.FilterInputStream | ||
| ↳ | java.io.PushbackInputStream | ||
A PushbackInputStream adds
functionality to another input stream, namely
the ability to "push back" or "unread" bytes,
by storing pushed-back bytes in an internal buffer.
This is useful in situations where
it is convenient for a fragment of code
to read an indefinite number of data bytes
that are delimited by a particular byte
value; after reading the terminating byte,
the code fragment can "unread" it, so that
the next read operation on the input stream
will reread the byte that was pushed back.
For example, bytes representing the characters
constituting an identifier might be terminated
by a byte representing an operator character;
a method whose job is to read just an identifier
can read until it sees the operator and
then push the operator back to be re-read.
Summary
Fields | |
|---|---|
protected
byte[] |
buf
The pushback buffer. |
protected
int |
pos
The position within the pushback buffer from which the next byte will be read. |
Inherited fields |
|---|
Public constructors | |
|---|---|
PushbackInputStream(InputStream in)
Creates a |
|
PushbackInputStream(InputStream in, int size)
Creates a |
|
Public methods | |
|---|---|
int
|
available()
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next |