Package com.lowagie.text.pdf
Class RandomAccessFileOrArray
- java.lang.Object
-
- com.lowagie.text.pdf.RandomAccessFileOrArray
-
-
Constructor Summary
Constructors Constructor Description RandomAccessFileOrArray(byte[] arrayIn)RandomAccessFileOrArray(RandomAccessFileOrArray file)RandomAccessFileOrArray(InputStream is)RandomAccessFileOrArray(String filename)RandomAccessFileOrArray(String filename, boolean forceRead, boolean plainRandomAccess)RandomAccessFileOrArray(URL url)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intgetFilePointer()ByteBuffergetNioByteBuffer()intgetStartOffset()Getter for property startOffset.static byte[]InputStreamToArray(InputStream is)protected voidinsureOpen()booleanisOpen()intlength()voidpushBack(byte b)intread()intread(byte[] b)intread(byte[] b, int off, int len)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)
-
-
-
Constructor Detail
-
RandomAccessFileOrArray
public RandomAccessFileOrArray(String filename) throws IOException
- Throws:
IOException
-
RandomAccessFileOrArray
public RandomAccessFileOrArray(String filename, boolean forceRead, boolean plainRandomAccess) throws IOException
- Throws:
IOException
-
RandomAccessFileOrArray
public RandomAccessFileOrArray(URL url) throws IOException
- Throws:
IOException
-
RandomAccessFileOrArray
public RandomAccessFileOrArray(InputStream is) throws IOException
- Throws:
IOException
-
RandomAccessFileOrArray
public RandomAccessFileOrArray(byte[] arrayIn)
-
RandomAccessFileOrArray
public RandomAccessFileOrArray(RandomAccessFileOrArray file)
-
-
Method Detail
-
InputStreamToArray
public static byte[] InputStreamToArray(InputStream is) throws IOException
- Throws:
IOException
-
pushBack
public void pushBack(byte b)
-
read
public int read() throws IOException- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Throws:
IOException
-
read
public int read(byte[] b) throws IOException- Throws:
IOException
-
readFully
public void readFully(byte[] b) throws IOException- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws IOException- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Throws:
IOException
-
skipBytes
public int skipBytes(int n) throws IOException- Specified by:
skipBytesin interfaceDataInput- Throws:
IOException
-
reOpen
public void reOpen() throws IOException- Throws:
IOException
-
insureOpen
protected void insureOpen() throws IOException- Throws:
IOException
-
isOpen
public boolean isOpen()
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
length
public int length() throws IOException- Throws:
IOException
-
seek
public void seek(int pos) throws IOException- Throws:
IOException
-
seek
public void seek(long pos) throws IOException- Throws:
IOException
-
getFilePointer
public int getFilePointer() throws IOException- Throws:
IOException
-
readBoolean
public boolean readBoolean() throws IOException- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
public byte readByte() throws IOException- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
public int readUnsignedByte() throws IOException- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readShort
public short readShort() throws IOException- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readShortLE
public final short readShortLE() throws IOExceptionReads 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, areb1andb2, where each of the two values is between0and255, 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.
-
readUnsignedShort
public int readUnsignedShort() throws IOException- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readUnsignedShortLE
public final int readUnsignedShortLE() throws IOExceptionReads 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, areb1andb2, where0 <= b1, b2 <= 255, then the result is equal to:(b2 << 8) | b1This 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.
-
readChar
public char readChar() throws IOException- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readCharLE
public final char readCharLE() throws IOExceptionReads 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, areb1andb2, where0 <= 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.
-
readInt
public int readInt() throws IOException- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readIntLE
public final int readIntLE() throws IOExceptionReads 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, areb1,b2,b3, andb4, where0 <= b1, b2, b3, b4 <= 255, then the result is equal to:(b4 << 24) | (b3 << 16) + (b2 << 8) + b1This 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.
-
readUnsignedInt
public final long readUnsignedInt() throws IOExceptionReads 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, areb1,b2,b3, andb4, where0 <= b1, b2, b3, b4 <= 255, then the result is equal to:(b1 << 24) | (b2 << 16) + (b3 << 8) + b4This 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() throws IOException- Throws:
IOException
-
readLong
public long readLong() throws IOException- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readLongLE
public final long readLongLE() throws IOException- Throws:
IOException
-
readFloat
public float readFloat() throws IOException- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readFloatLE
public final float readFloatLE() throws IOException- Throws:
IOException
-
readDouble
public double readDouble() throws IOException- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readDoubleLE
public final double readDoubleLE() throws IOException- Throws:
IOException
-
readLine
public String readLine() throws IOException
- Specified by:
readLinein interfaceDataInput- Throws:
IOException
-
readUTF
public String readUTF() throws IOException
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
getStartOffset
public int getStartOffset()
Getter for property startOffset.- Returns:
- Value of property startOffset.
-
setStartOffset
public void setStartOffset(int startOffset)
Setter for property startOffset.- Parameters:
startOffset- New value of property startOffset.
-
getNioByteBuffer
public ByteBuffer getNioByteBuffer() throws IOException
- Returns:
- a ByteBuffer
- Throws:
IOException- on error- Since:
- 2.0.8
-
-