java.io
Class PushbackInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--java.io.PushbackInputStream

public class PushbackInputStream
extends FilterInputStream

An input stream that has a 1 byte push back buffer.


Field Summary
protected  int pushBack
          Push back character.
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
PushbackInputStream(InputStream in)
          Creates a PushbackInputStream.
 
Method Summary
 int available()
          Returns the number of bytes that can be read.
 boolean markSupported()
          Returns true if this stream type supports mark/reset.
 int read()
          Reads a byte of data.
 int read(byte[] bytes, int offset, int length)
          Reads into an array of bytes.
 void unread(int ch)
          Pushes back a character.
 
Methods inherited from class java.io.FilterInputStream
close, mark, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pushBack

protected int pushBack
Push back character.

Constructor Detail

PushbackInputStream

public PushbackInputStream(InputStream in)
Creates a PushbackInputStream.

Parameters:
in - the input stream
Method Detail

read

public int read()
         throws IOException
Reads a byte of data. This method will block if no input is available.

Overrides:
read in class FilterInputStream
Returns:
the byte read, or -1 if the end of the stream is reached.
Throws:
IOException - If an I/O error has occurred.

read

public int read(byte[] bytes,
                int offset,
                int length)
         throws IOException
Reads into an array of bytes. This method blocks until some input is available.

Overrides:
read in class FilterInputStream
Parameters:
bytes - the buffer into which the data is read
offset - the start offset of the data
length - the maximum number of bytes read
Returns:
the actual number of bytes read, -1 is returned when the end of the stream is reached.
Throws:
IOException - If an I/O error has occurred.

unread

public void unread(int ch)
            throws IOException
Pushes back a character.

Parameters:
ch - the character to push back.
Throws:
IOException - If an attempt to push back more than one character is made.

available

public int available()
              throws IOException
Returns the number of bytes that can be read. without blocking.

Overrides:
available in class FilterInputStream
Returns:
the number of available bytes
IOException

markSupported

public boolean markSupported()
Returns true if this stream type supports mark/reset.

Overrides:
markSupported in class FilterInputStream
Returns:
true if this stream type supports mark/reset; false otherwise.