Top Description Methods
org.apache.pdfbox.io

public Interface RandomAccessRead

extends Closeable
Known Direct Subinterfaces
org.apache.pdfbox.io.RandomAccess
Known Direct Implementers
org.apache.pdfbox.io.RandomAccessReadBuffer, org.apache.pdfbox.io.RandomAccessReadBufferedFile, org.apache.pdfbox.io.RandomAccessReadMemoryMappedFile, org.apache.pdfbox.io.RandomAccessReadView, org.apache.pdfbox.io.SequenceRandomAccessRead, org.apache.pdfbox.io.NonSeekableRandomAccessReadInputStream
Imports
java.io.Closeable, .IOException

An interface allowing random access read operations.

Method Summary

Modifier and TypeMethod and Description
public default int

Returns:

the number of bytes that can be read
available
()

Returns an estimate of the number of bytes that can be read.

public RandomAccessReadView

Returns:

the random access read view
createView
(long
start position within the underlying random access read
startPosition
,
long
stream length
streamLength
)

Creates a random access read view starting at the given position with the given length.

public long

Returns:

offset of next byte which will be returned with next read() (if no more bytes are left it returns a value >= length of source)
getPosition
()

Returns offset of next byte to be returned by a read method.

public boolean

Returns:

true if the source has been closed
isClosed
()

Returns true if this source has been closed.

public boolean

Returns:

true if we are at the end of the data.
isEOF
()

A simple test to see if we are at the end of the data.

public long

Returns:

The number of bytes available.
length
()

The total number of bytes that are available.

public default int

Returns:

The next byte on the stream, leaving it as available to read.
peek
()

This will peek at the next byte.

public int

Returns:

The byte of data that is being read.
read
()

Read a single byte of data.

public default int

Returns:

The number of bytes that were actually read.
read
(byte[]
The buffer to write the data to.
b
)

Read a buffer of data.

public int

Returns:

The number of bytes that were actually read.
read
(byte[]
The buffer to write the data to.
b
,
int
Offset into the buffer to start writing.
offset
,
int
The amount of data to attempt to read.
length
)

Read a buffer of data.

public default void
rewind(int
the number of bytes to be seeked backwards
bytes
)

Seek backwards the given number of bytes.

public void
seek(long
The position to seek to.
position
)

Seek to a position in the data.

public default void
skip(int
the number of bytes to be skipped
length
)

Skips a given number of bytes.

Inherited from java.io.Closeable:
close

Method Detail

availableback to summary
public default int available() throws IOException

Returns an estimate of the number of bytes that can be read.

Returns:int

the number of bytes that can be read

Exceptions
IOException:
if this random access has been closed
createViewback to summary
public RandomAccessReadView createView(long startPosition, long streamLength) throws IOException

Creates a random access read view starting at the given position with the given length.

Parameters
startPosition:long

start position within the underlying random access read

streamLength:long

stream length

Returns:RandomAccessReadView

the random access read view

Exceptions
IOException:
if something went wrong when creating the view for the RandomAccessRead
getPositionback to summary
public long getPosition() throws IOException

Returns offset of next byte to be returned by a read method.

Returns:long

offset of next byte which will be returned with next read() (if no more bytes are left it returns a value >= length of source)

Exceptions
IOException:
If there was an error while getting the current position
isClosedback to summary
public boolean isClosed()

Returns true if this source has been closed.

Returns:boolean

true if the source has been closed

isEOFback to summary
public boolean isEOF() throws IOException

A simple test to see if we are at the end of the data.

Returns:boolean

true if we are at the end of the data.

Exceptions
IOException:
If there is an error reading the next byte.
lengthback to summary
public long length() throws IOException

The total number of bytes that are available.

Returns:long

The number of bytes available.

Exceptions
IOException:
If there is an IO error while determining the length of the data stream.
peekback to summary
public default int peek() throws IOException

This will peek at the next byte.

Returns:int

The next byte on the stream, leaving it as available to read.

Exceptions
IOException:
If there is an error reading the next byte.
readback to summary
public int read() throws IOException

Read a single byte of data.

Returns:int

The byte of data that is being read.

Exceptions
IOException:
If there is an error while reading the data.
readback to summary
public default int read(byte[] b) throws IOException

Read a buffer of data.

Parameters
b:byte[]

The buffer to write the data to.

Returns:int

The number of bytes that were actually read.

Exceptions
IOException:
If there was an error while reading the data.
readback to summary
public int read(byte[] b, int offset, int length) throws IOException

Read a buffer of data.

Parameters
b:byte[]

The buffer to write the data to.

offset:int

Offset into the buffer to start writing.

length:int

The amount of data to attempt to read.

Returns:int

The number of bytes that were actually read.

Exceptions
IOException:
If there was an error while reading the data.
rewindback to summary
public default void rewind(int bytes) throws IOException

Seek backwards the given number of bytes.

Parameters
bytes:int

the number of bytes to be seeked backwards

Exceptions
IOException:
If there is an error while seeking
seekback to summary
public void seek(long position) throws IOException

Seek to a position in the data.

Parameters
position:long

The position to seek to.

Exceptions
IOException:
If there is an error while seeking.
skipback to summary
public default void skip(int length) throws IOException

Skips a given number of bytes.

Parameters
length:int

the number of bytes to be skipped

Exceptions
IOException:
if an I/O error occurs while reading data