org.apache.pdfbox.io
Interface RandomAccess

All Known Implementing Classes:
RandomAccessBuffer, RandomAccessFile

public interface RandomAccess

An interface to allow PDF files to be stored completely in memory or to use a scratch file on the disk.

Version:
$Revision: 1.2 $
Author:
Ben Litchfield

Method Summary
 void close()
          Release resources that are being held.
 long length()
          The total number of bytes that are available.
 int read()
          Read a single byte of data.
 int read(byte[] b, int offset, int length)
          Read a buffer of data.
 void seek(long position)
          Seek to a position in the data.
 void write(byte[] b, int offset, int length)
          Write a buffer of data to the stream.
 void write(int b)
          Write a byte to the stream.
 

Method Detail

close

void close()
           throws IOException
Release resources that are being held.

Throws:
IOException - If there is an error closing this resource.

seek

void seek(long position)
          throws IOException
Seek to a position in the data.

Parameters:
position - The position to seek to.
Throws:
IOException - If there is an error while seeking.

read

int read()
         throws IOException
Read a single byte of data.

Returns:
The byte of data that is being read.
Throws:
IOException - If there is an error while reading the data.

read

int read(byte[] b,
         int offset,
         int length)
         throws IOException
Read a buffer of data.

Parameters:
b - The buffer to write the data to.
offset - Offset into the buffer to start writing.
length - The amount of data to attempt to read.
Returns:
The number of bytes that were actually read.
Throws:
IOException - If there was an error while reading the data.

length

long length()
            throws IOException
The total number of bytes that are available.

Returns:
The number of bytes available.
Throws:
IOException - If there is an IO error while determining the length of the data stream.

write

void write(int b)
           throws IOException
Write a byte to the stream.

Parameters:
b - The byte to write.
Throws:
IOException - If there is an IO error while writing.

write

void write(byte[] b,
           int offset,
           int length)
           throws IOException
Write a buffer of data to the stream.

Parameters:
b - The buffer to get the data from.
offset - An offset into the buffer to get the data from.
length - The length of data to write.
Throws:
IOException - If there is an error while writing the data.


Copyright © 2002-2010 The Apache Software Foundation. All Rights Reserved.