|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.io.PushbackInputStream
org.apache.pdfbox.io.PushBackInputStream
org.apache.pdfbox.io.ByteArrayPushBackInputStream
public class ByteArrayPushBackInputStream
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().
Field Summary |
---|
Fields inherited from class java.io.PushbackInputStream |
---|
buf, pos |
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
ByteArrayPushBackInputStream(byte[] input)
Constructor. |
Method Summary | |
---|---|
int |
available()
Available bytes. |
boolean |
isEOF()
A simple test to see if we are at the end of the stream. |
int |
localRead(byte[] buffer,
int off,
int len)
Read a number of bytes. |
void |
mark(int readlimit)
Save the state of this stream. |
boolean |
markSupported()
Check if mark is supported. |
int |
peek()
This will peek at the next byte. |
int |
read()
Read a byte. |
int |
read(byte[] buffer)
Read a number of bytes. |
int |
read(byte[] buffer,
int off,
int len)
Read a number of bytes. |
void |
reset()
Restore the state of this stream to the last saveState call. |
int |
seek(int newpos)
Position the stream at a given index. |
int |
size()
Totally available bytes in the underlying array. |
long |
skip(long num)
Skips over and discards n bytes of data from this input stream. |
void |
unread(byte[] buffer)
Pushes back a portion of an array of bytes by copying it to the front of the pushback buffer. |
void |
unread(byte[] buffer,
int off,
int len)
Pushes back a portion of an array of bytes by copying it to the front of the pushback buffer. |
void |
unread(int by)
Pushes back a byte. |
Methods inherited from class org.apache.pdfbox.io.PushBackInputStream |
---|
fillBuffer, getOffset, readFully, seek |
Methods inherited from class java.io.PushbackInputStream |
---|
close |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ByteArrayPushBackInputStream(byte[] input) throws IOException
input
- Data to read from. Note that calls to unread() will
modify this array! If this is not desired, pass a copy.
IOException
- If there is an IO error.Method Detail |
---|
public int peek()
peek
in class PushBackInputStream
public boolean isEOF()
isEOF
in class PushBackInputStream
public void mark(int readlimit)
mark
in class PushbackInputStream
readlimit
- Has no effect.InputStream.mark(int)
public boolean markSupported()
markSupported
in class PushbackInputStream
InputStream.markSupported()
public void reset()
reset
in class PushbackInputStream
InputStream.reset()
public int available()
available
in class PushbackInputStream
InputStream.available()
public int size()
public void unread(int by) throws IOException
unread
in class PushBackInputStream
by
- the int value whose low-order byte is to be pushed back.
IOException
- - If there is not enough room in the buffer for the byte.PushbackInputStream.unread(int)
public void unread(byte[] buffer, int off, int len) throws IOException
unread
in class PushBackInputStream
buffer
- the byte array to push back.off
- the start offset of the data.len
- the number of bytes to push back.
IOException
- If there is not enough room in the pushback buffer
for the specified number of bytes.PushbackInputStream.unread(byte[], int, int)
public void unread(byte[] buffer) throws IOException
unread
in class PushBackInputStream
buffer
- the byte array to push back.
IOException
- If there is not enough room in the pushback buffer
for the specified number of bytes.PushbackInputStream.unread(byte[])
public int read()
read
in class PushBackInputStream
InputStream.read()
public int read(byte[] buffer)
read
in class PushBackInputStream
buffer
- the buffer into which the data is read.
InputStream.read(byte[])
public int read(byte[] buffer, int off, int len)
read
in class PushBackInputStream
buffer
- the buffer into which the data is read.off
- the start offset in array buffer at which the data is written.len
- the maximum number of bytes to read.
InputStream.read(byte[], int, int)
public int localRead(byte[] buffer, int off, int len)
buffer
- the buffer into which the data is read.off
- the start offset in array buffer at which the data is written.len
- the maximum number of bytes to read.
InputStream.read(byte[], int, int)
public long skip(long num)
skip
in class PushbackInputStream
num
- the number of bytes to be skipped.
InputStream.skip(long)
public int seek(int newpos)
newpos
- Position in the underlying array. A negative value will be
interpreted as 0, a value greater than size() as size().
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |