com.lowagie.text.pdf

Class RandomAccessFileOrArray

public class RandomAccessFileOrArray extends Object implements DataInput

An implementation of a RandomAccessFile for input only that accepts a file or a byte array as data source.

Author: Paulo Soares (psoares@consiste.pt)

Field Summary
byte[]arrayIn
intarrayInPtr
byteback
Stringfilename
booleanisBack
MappedRandomAccessFilerf
intstartOffset
Holds value of property startOffset.
Constructor Summary
RandomAccessFileOrArray(String filename)
RandomAccessFileOrArray(String filename, boolean forceRead)
RandomAccessFileOrArray(URL url)
RandomAccessFileOrArray(InputStream is)
RandomAccessFileOrArray(byte[] arrayIn)
RandomAccessFileOrArray(RandomAccessFileOrArray file)
Method Summary
voidclose()
intgetFilePointer()
intgetStartOffset()
Getter for property startOffset.
protected voidinsureOpen()
booleanisOpen()
static byte[]InputStreamToArray(InputStream is)
intlength()
voidpushBack(byte b)
intread()
intread(byte[] b, int off, int len)
intread(byte[] b)
booleanreadBoolean()
bytereadByte()
charreadChar()
charreadCharLE()
Reads a Unicode character from this stream in little-endian order.
doublereadDouble()
doublereadDoubleLE()
floatreadFloat()
floatreadFloatLE()
voidreadFully(byte[] b)
voidreadFully(byte[] b, int off, int len)
intreadInt()
intreadIntLE()
Reads a signed 32-bit integer from this stream in little-endian order.
StringreadLine()
longreadLong()
longreadLongLE()
shortreadShort()
shortreadShortLE()
Reads a signed 16-bit number from this stream in little-endian order.
intreadUnsignedByte()
longreadUnsignedInt()
Reads an unsigned 32-bit integer from this stream.
longreadUnsignedIntLE()
intreadUnsignedShort()
intreadUnsignedShortLE()
Reads an unsigned 16-bit number from this stream in little-endian order.
StringreadUTF()
voidreOpen()
voidseek(int pos)
voidseek(long pos)
voidsetStartOffset(int startOffset)
Setter for property startOffset.
longskip(long n)
intskipBytes(int n)

Field Detail

arrayIn

byte[] arrayIn

arrayInPtr

int arrayInPtr

back

byte back

filename

String filename

isBack

boolean isBack

rf

MappedRandomAccessFile rf

startOffset

private int startOffset
Holds value of property startOffset.

Constructor Detail

RandomAccessFileOrArray

public RandomAccessFileOrArray(String filename)

RandomAccessFileOrArray

public RandomAccessFileOrArray(String filename, boolean forceRead)

RandomAccessFileOrArray

public RandomAccessFileOrArray(URL url)

RandomAccessFileOrArray

public RandomAccessFileOrArray(InputStream is)

RandomAccessFileOrArray

public RandomAccessFileOrArray(byte[] arrayIn)

RandomAccessFileOrArray

public RandomAccessFileOrArray(RandomAccessFileOrArray file)

Method Detail

close

public void close()

getFilePointer

public int getFilePointer()

getStartOffset

public int getStartOffset()
Getter for property startOffset.

Returns: Value of property startOffset.

insureOpen

protected void insureOpen()

isOpen

public boolean isOpen()

InputStreamToArray

public static byte[] InputStreamToArray(InputStream is)

length

public int length()

pushBack

public void pushBack(byte b)

read

public int read()

read

public int read(byte[] b, int off, int len)

read

public int read(byte[] b)

readBoolean

public boolean readBoolean()

readByte

public byte readByte()

readChar

public char readChar()

readCharLE

public final char readCharLE()
Reads a Unicode character from this stream in little-endian order. This method reads two bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 and b2, where 0 <= b1, b2 <= 255, then the result is equal to:
     (char)((b2 << 8) | b1)
 

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Returns: the next two bytes of this stream as a Unicode character.

Throws: EOFException if this stream reaches the end before reading two bytes. IOException if an I/O error occurs.

readDouble

public double readDouble()

readDoubleLE

public final double readDoubleLE()

readFloat

public float readFloat()

readFloatLE

public final float readFloatLE()

readFully

public void readFully(byte[] b)

readFully

public void readFully(byte[] b, int off, int len)

readInt

public int readInt()

readIntLE

public final int readIntLE()
Reads a signed 32-bit integer from this stream in little-endian order. This method reads 4 bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1, b2, b3, and b4, where 0 <= b1, b2, b3, b4 <= 255, then the result is equal to:
     (b4 << 24) | (b3 << 16) + (b2 << 8) + b1
 

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

Returns: the next four bytes of this stream, interpreted as an int.

Throws: EOFException if this stream reaches the end before reading four bytes. IOException if an I/O error occurs.

readLine

public String readLine()

readLong

public long readLong()

readLongLE

public final long readLongLE()

readShort

public short readShort()

readShortLE

public final short readShortLE()
Reads a signed 16-bit number from this stream in little-endian order. The method reads two bytes from this stream, starting at the current stream pointer. If the two bytes read, in order, are b1 and b2, where each of the two values is between 0 and 255, inclusive, then the result is equal to:
     (short)((b2 << 8) | b1)
 

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Returns: the next two bytes of this stream, interpreted as a signed 16-bit number.

Throws: EOFException if this stream reaches the end before reading two bytes. IOException if an I/O error occurs.

readUnsignedByte

public int readUnsignedByte()

readUnsignedInt

public final long readUnsignedInt()
Reads an unsigned 32-bit integer from this stream. This method reads 4 bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1, b2, b3, and b4, where 0 <= b1, b2, b3, b4 <= 255, then the result is equal to:
     (b1 << 24) | (b2 << 16) + (b3 << 8) + b4
 

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

Returns: the next four bytes of this stream, interpreted as a long.

Throws: EOFException if this stream reaches the end before reading four bytes. IOException if an I/O error occurs.

readUnsignedIntLE

public final long readUnsignedIntLE()

readUnsignedShort

public int readUnsignedShort()

readUnsignedShortLE

public final int readUnsignedShortLE()
Reads an unsigned 16-bit number from this stream in little-endian order. This method reads two bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 and b2, where 0 <= b1, b2 <= 255, then the result is equal to:
     (b2 << 8) | b1
 

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Returns: the next two bytes of this stream, interpreted as an unsigned 16-bit integer.

Throws: EOFException if this stream reaches the end before reading two bytes. IOException if an I/O error occurs.

readUTF

public String readUTF()

reOpen

public void reOpen()

seek

public void seek(int pos)

seek

public void seek(long pos)

setStartOffset

public void setStartOffset(int startOffset)
Setter for property startOffset.

Parameters: startOffset New value of property startOffset.

skip

public long skip(long n)

skipBytes

public int skipBytes(int n)