Home » pdfbox-1.1.0-src » org.apache.pdfbox.io » [javadoc | source]
org.apache.pdfbox.io
public class: ByteArrayPushBackInputStream [javadoc | source]
java.lang.Object
   java.io.InputStream
      java.io.FilterInputStream
         java.io.PushbackInputStream
            org.apache.pdfbox.io.PushBackInputStream
               org.apache.pdfbox.io.ByteArrayPushBackInputStream

All Implemented Interfaces:
    Closeable

PushBackInputStream for byte arrays. The inheritance from PushBackInputStream is only to avoid the introduction of an interface with all PushBackInputStream methods. The parent PushBackInputStream is not used in any way and all methods are overridden. (Thus when adding new methods to PushBackInputStream override them in this class as well!) unread() is limited to the number of bytes already read from this stream (i.e. the current position in the array). This limitation usually poses no problem to a parser, but allows for some optimization since only one array has to be dealt with. Note: This class is not thread safe. Clients must provide synchronization if needed. Note: Calling unread() after mark() will cause (part of) the unread data to be read again after reset(). Thus do not call unread() between mark() and reset().
Fields inherited from java.io.PushbackInputStream:
buf,  pos
Fields inherited from java.io.FilterInputStream:
in
Constructor:
 public ByteArrayPushBackInputStream(byte[] input) throws IOException 
    Constructor.
    Parameters:
    input - Data to read from. Note that calls to unread() will modify this array! If this is not desired, pass a copy.
    Throws:
    IOException - If there is an IO error.
Method from org.apache.pdfbox.io.ByteArrayPushBackInputStream Summary:
available,   isEOF,   localRead,   mark,   markSupported,   peek,   read,   read,   read,   reset,   seek,   size,   skip,   unread,   unread,   unread
Methods from org.apache.pdfbox.io.PushBackInputStream:
fillBuffer,   getOffset,   isEOF,   peek,   read,   read,   read,   readFully,   unread,   unread,   unread
Methods from java.io.PushbackInputStream:
available,   close,   mark,   markSupported,   read,   read,   reset,   skip,   unread,   unread,   unread
Methods from java.io.FilterInputStream:
available,   close,   mark,   markSupported,   read,   read,   read,   reset,   skip
Methods from java.io.InputStream:
available,   close,   mark,   markSupported,   read,   read,   read,   reset,   skip
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.pdfbox.io.ByteArrayPushBackInputStream Detail:
 public int available() 
    Available bytes.
 public boolean isEOF() 
    A simple test to see if we are at the end of the stream.
 public int localRead(byte[] buffer,
    int off,
    int len) 
    Read a number of bytes. Internal method that assumes off and len to be valid.
 public  void mark(int readlimit) 
    Save the state of this stream.
 public boolean markSupported() 
    Check if mark is supported.
 public int peek() 
    This will peek at the next byte.
 public int read() 
    Read a byte.
 public int read(byte[] buffer) 
    Read a number of bytes.
 public int read(byte[] buffer,
    int off,
    int len) 
    Read a number of bytes.
 public  void reset() 
    Restore the state of this stream to the last saveState call.
 public int seek(int newpos) 
    Position the stream at a given index. Positioning the stream at position size() will cause the next call to read() to return -1.
 public int size() 
    Totally available bytes in the underlying array.
 public long skip(long num) 
    Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.
 public  void unread(int by) throws IOException 
    Pushes back a byte. After this method returns, the next byte to be read will have the value (byte)by.
 public  void unread(byte[] buffer) throws IOException 
    Pushes back a portion of an array of bytes by copying it to the front of the pushback buffer. After this method returns, the next byte to be read will have the value buffer[0], the byte after that will have the value buffer[1], and so forth.
 public  void unread(byte[] buffer,
    int off,
    int len) throws IOException 
    Pushes back a portion of an array of bytes by copying it to the front of the pushback buffer. After this method returns, the next byte to be read will have the value b[off], the byte after that will have the value b[off+1], and so forth.