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.
-
buf
- The push back buffer.
-
pos
- The current position within the buffer.
-
PushbackInputStream(InputStream)
- Creates a new input stream with a 1 byte push back buffer.
-
PushbackInputStream(InputStream, int)
- Creates a new input stream with a push back buffer of specified size.
-
available()
- Returns the number of bytes that can be read without blocking.
-
markSupported()
- Returns true if this stream type supports mark/reset.
-
read()
- Reads a byte of data.
-
read(byte[], int, int)
- Reads into an array of bytes.
-
unread(byte[])
- Pushes back an array of bytes.
-
unread(byte[], int, int)
- Pushes back an array of bytes.
-
unread(int)
- Pushes back a byte.
buf
protected byte buf[]
- The push back buffer.
pos
protected int pos
- The current position within the buffer.
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
PushbackInputStream
public PushbackInputStream(InputStream in)
- Creates a new input stream with a 1 byte push back buffer.
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
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
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.
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.
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.
available
public int available() throws IOException
- Returns the number of bytes that can be read without blocking.
- Overrides:
- available in class FilterInputStream
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