22.13
java.io.PushbackInputStream
THE PACKAGE JAVA.IO
22.13 The Class
java.io.PushbackInputStream
A
PushbackInputStream
adds functionality to another input stream, namely the
ability to push back or unread one byte. 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.
public class PushbackInputStream extends FilterInputStream {
protected int pushBack = 1;
public PushbackInputStream(InputStream in);
public int read() throws IOException;
public int read(byte[] bytes, int offset, int length)
throws IOException, NullPointerException,
IndexOutOfBoundsException;
public void unread(int ch) throws IOException;
public int available() throws IOException;
public boolean markSupported();
}
22.13.1
protected int pushBack = 1;
If this field has a nonnegative value, it is a byte that was pushed back. If this field
is
1
, there is currently no pushed back byte.
22.13.2
public PushbackInputStream(InputStream in)
This constructor initializes a newly created
PushbackInputStream
by saving its
argument, the input stream
in
, for later use. Initially, there is no pushed back byte
(the field
pushBack
is initialized to
1
).
22.13.3
public int read() throws IOException
See the general contract of the
read
method of
InputStream
( 22.3.1).
If
pushBack
is not
1
, the value of
pushBack
is returned and
pushBack
is set
to
1
. Otherwise, a byte is obtained from the contained input stream.
Overrides the
read
method of
FilterInputStream
( 22.9.3).
710
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved