com.neoworks.util
Class PushBackInputStream

java.lang.Object
  |
  +--com.neoworks.util.PushBackInputStream

public class PushBackInputStream
extends java.lang.Object

Push back InputStream. This is an InputStream (not standard) that allows data to be pushed back and subsequently reread.

Author:
Nigel Atkinson (nigel@neoworks.com)
, Original author unknown

Constructor Summary
PushBackInputStream(java.io.InputStream in)
          Public constructor
 
Method Summary
 void close()
          Close the stream.
 long getPos()
          Get the position in the Stream
 int read(byte[] b, int off, int len)
          Read bytes from the stream into an array
 void unread(byte[] b, int off, int len)
          Unread bytes from the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushBackInputStream

public PushBackInputStream(java.io.InputStream in)
Public constructor

Parameters:
in - The InputStream to wrap
Method Detail

getPos

public long getPos()
Get the position in the Stream

Returns:
the position in the stream

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read bytes from the stream into an array

Parameters:
b - The byte array to read into
off - The offset into the byte array to begin reading into
len - The number of bytes to read
Returns:
The number of bytes read
Throws:
java.io.IOException

unread

public void unread(byte[] b,
                   int off,
                   int len)
Unread bytes from the stream.

Parameters:
b - An array of bytes to push back onto the stream
off - The offset into the byte array to push back from
len - The number of bytes to push back.

close

public void close()
           throws java.io.IOException
Close the stream.

Throws:
java.io.IOException