All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.io.PushbackInputStream

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

public class PushbackInputStream
extends FilterInputStream
This class implements an input stream filter that lets you "push back" bytes that have previously been read.


Variable Index

 o buf
The push back buffer.
 o pos
The current position within the buffer.

Constructor Index

 o PushbackInputStream(InputStream)
Creates a new input stream with a 1 byte push back buffer.
 o PushbackInputStream(InputStream, int)
Creates a new input stream with a push back buffer of specified size.

Method Index

 o available()
Returns the number of bytes that can be read without blocking.
 o markSupported()
Returns true if this stream type supports mark/reset.
 o read()
Reads a byte of data.
 o read(byte[], int, int)
Reads into an array of bytes.
 o unread(byte[])
Pushes back an array of bytes.
 o unread(byte[], int, int)
Pushes back an array of bytes.
 o unread(int)
Pushes back a byte.

Variables

 o buf
  protected byte buf[]
The push back buffer.

 o pos
  protected int pos
The current position within the buffer.

Constructors

 o PushbackInputStream
  public PushbackInputStream(InputStream in,
                             int size)
Creates a new input stream with a push back buffer of specified size.

Parameters:
size - the size of the push back buffer
 o PushbackInputStream
  public PushbackInputStream(InputStream in)
Creates a new input stream with a 1 byte push back buffer.

Methods

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

Returns:
the byte read, or -1 if the end of the stream is reached.
Throws: IOException
If an I/O error has occurred.
Overrides:
read in class FilterInputStream
 o read
  public int read(byte b[],
                  int off,
                  int len) throws IOException
Reads into an array of bytes. This method will block until some input is available.

Parameters:
b - the buffer into which the data is read
off - the start offset of the data
len - the maximum number of bytes read
Returns:
the actual number of bytes read, or -1 if the end of the stream is reached.
Throws: IOException
If an I/O error has occurred.
Overrides:
read in class FilterInputStream
 o unread
  public void unread(int b) throws IOException
Pushes back a byte.

Parameters:
b - the byte to push back.
Throws: IOException
If the push back buffer is full.
 o unread
  public void unread(byte b[],
                     int off,
                     int len) throws IOException
Pushes back an array of bytes.

Parameters:
b - the bytes to push back
off - the start offset of the data
len - the number of bytes to push back.
Throws: IOException
If there is not enough room in the push back buffer for the specified number of bytes.
 o unread
  public void unread(byte b[]) throws IOException
Pushes back an array of bytes.

Parameters:
b - the bytes to push back
Throws: IOException
If there is not enough room in the push back buffer for the specified number of bytes.
 o available
  public int available() throws IOException
Returns the number of bytes that can be read without blocking.

Overrides:
available in class FilterInputStream
 o markSupported
  public boolean markSupported()
Returns true if this stream type supports mark/reset.

Overrides:
markSupported in class FilterInputStream

All Packages  Class Hierarchy  This Package  Previous  Next  Index