public class DataInputRandomAccessRead extends Object implements DataInput
Integer.MAX_VALUE.
Straight forward reading may work, but getPosition() and setPosition(int)
may have problems.| Constructor and Description |
|---|
DataInputRandomAccessRead(org.apache.pdfbox.io.RandomAccessRead randomAccessRead)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getPosition()
Returns the current position.
|
boolean |
hasRemaining()
Determines if there are any bytes left to read or not.
|
int |
length() |
int |
peekUnsignedByte(int offset)
Peeks one single unsigned byte from the buffer.
|
byte |
readByte()
Read one single byte from the buffer.
|
byte[] |
readBytes(int length)
Read a number of single byte values from the buffer.
Note: when readBytes(5) is called, but there are only 3 bytes available, the
caller gets an IOException, not the 3 bytes! |
int |
readUnsignedByte()
Read one single unsigned byte from the buffer.
|
void |
setPosition(int position)
Sets the current absolute position to the given value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadInt, readOffset, readShort, readUnsignedShortpublic DataInputRandomAccessRead(org.apache.pdfbox.io.RandomAccessRead randomAccessRead)
randomAccessRead - the source to be read frompublic boolean hasRemaining()
throws IOException
hasRemaining in interface DataInputIOException - when the underlying buffer has already been closed.public int getPosition()
throws IOException
getPosition in interface DataInputIOException - when the underlying buffer has already been closed.public void setPosition(int position)
throws IOException
setPosition(-20) to move 20 bytes back!setPosition in interface DataInputposition - the given position, must be 0 ≤ position < length.IOException - if the new position is out of rangeor when the underlying buffer has
already been closed.public byte readByte()
throws IOException
readByte in interface DataInputIOException - when there are no bytes to reador when the underlying buffer has already
been closed.public int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOException - when there are no bytes to read or when the underlying buffer has already
been closed.public int peekUnsignedByte(int offset)
throws IOException
peekUnsignedByte in interface DataInputoffset - offset to the byte to be peeked, must be 0 ≤ offset.IOException - when the offset is negative or beyond end_of_buffer or when the
underlying buffer has been closed already.public byte[] readBytes(int length)
throws IOException
readBytes(5) is called, but there are only 3 bytes available, the
caller gets an IOException, not the 3 bytes!readBytes in interface DataInputlength - the number of bytes to be read, must be 0 ≤ length.IOException - when there are less than length bytes available or when the
underlying buffer has already been closed.public int length()
throws IOException
length in interface DataInputIOExceptionCopyright © 2008–2025 The Apache Software Foundation. All rights reserved.