|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.itextpdf.text.pdf.RandomAccessFileOrArray
public class RandomAccessFileOrArray
An implementation of a RandomAccessFile for input only that accepts a file or a byte array as data source.
Constructor Summary | |
---|---|
RandomAccessFileOrArray(byte[] arrayIn)
|
|
RandomAccessFileOrArray(InputStream is)
|
|
RandomAccessFileOrArray(RandomAccessFileOrArray file)
|
|
RandomAccessFileOrArray(String filename)
|
|
RandomAccessFileOrArray(String filename,
boolean forceRead,
boolean plainRandomAccess)
Constructs a new RandomAccessFileOrArrayObject |
|
RandomAccessFileOrArray(URL url)
|
Method Summary | |
---|---|
void |
close()
|
long |
getFilePointer()
|
ByteBuffer |
getNioByteBuffer()
|
long |
getStartOffset()
Getter for property startOffset. |
static byte[] |
InputStreamToArray(InputStream is)
|
protected void |
insureOpen()
|
boolean |
isOpen()
|
long |
length()
|
void |
pushBack(byte b)
|
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
boolean |
readBoolean()
|
byte |
readByte()
|
char |
readChar()
|
char |
readCharLE()
Reads a Unicode character from this stream in little-endian order. |
double |
readDouble()
|
double |
readDoubleLE()
|
float |
readFloat()
|
float |
readFloatLE()
|
void |
readFully(byte[] b)
|
void |
readFully(byte[] b,
int off,
int len)
|
int |
readInt()
|
int |
readIntLE()
Reads a signed 32-bit integer from this stream in little-endian order. |
String |
readLine()
|
long |
readLong()
|
long |
readLongLE()
|
short |
readShort()
|
short |
readShortLE()
Reads a signed 16-bit number from this stream in little-endian order. |
int |
readUnsignedByte()
|
long |
readUnsignedInt()
Reads an unsigned 32-bit integer from this stream. |
long |
readUnsignedIntLE()
|
int |
readUnsignedShort()
|
int |
readUnsignedShortLE()
Reads an unsigned 16-bit number from this stream in little-endian order. |
String |
readUTF()
|
void |
reOpen()
|
void |
seek(long pos)
|
void |
setStartOffset(long startOffset)
Setter for property startOffset. |
long |
skip(long n)
|
int |
skipBytes(int n)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RandomAccessFileOrArray(String filename) throws IOException
IOException
public RandomAccessFileOrArray(String filename, boolean forceRead, boolean plainRandomAccess) throws IOException
filename
- the file to open (can be a file system file or one of the following url strings: file://, http://, https://, jar:, wsjar:, vfszip:forceRead
- if true, the entire file will be read into memoryplainRandomAccess
- if true, a regular RandomAccessFile is used to access the file contents. If false, a memory mapped file will be used, unless the file cannot be mapped into memory, in which case regular RandomAccessFile will be used
IOException
- if there is a failure opening or reading the filepublic RandomAccessFileOrArray(URL url) throws IOException
IOException
public RandomAccessFileOrArray(InputStream is) throws IOException
IOException
public RandomAccessFileOrArray(byte[] arrayIn)
public RandomAccessFileOrArray(RandomAccessFileOrArray file)
Method Detail |
---|
public static byte[] InputStreamToArray(InputStream is) throws IOException
IOException
public void pushBack(byte b)
public int read() throws IOException
IOException
public int read(byte[] b, int off, int len) throws IOException
IOException
public int read(byte[] b) throws IOException
IOException
public void readFully(byte[] b) throws IOException
readFully
in interface DataInput
IOException
public void readFully(byte[] b, int off, int len) throws IOException
readFully
in interface DataInput
IOException
public long skip(long n) throws IOException
IOException
public int skipBytes(int n) throws IOException
skipBytes
in interface DataInput
IOException
public void reOpen() throws IOException
IOException
protected void insureOpen() throws IOException
IOException
public boolean isOpen()
public void close() throws IOException
IOException
public long length() throws IOException
IOException
public void seek(long pos) throws IOException
IOException
public long getFilePointer() throws IOException
IOException
public boolean readBoolean() throws IOException
readBoolean
in interface DataInput
IOException
public byte readByte() throws IOException
readByte
in interface DataInput
IOException
public int readUnsignedByte() throws IOException
readUnsignedByte
in interface DataInput
IOException
public short readShort() throws IOException
readShort
in interface DataInput
IOException
public final short readShortLE() throws IOException
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.
EOFException
- if this stream reaches the end before reading
two bytes.
IOException
- if an I/O error occurs.public int readUnsignedShort() throws IOException
readUnsignedShort
in interface DataInput
IOException
public final int readUnsignedShortLE() throws IOException
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.
EOFException
- if this stream reaches the end before reading
two bytes.
IOException
- if an I/O error occurs.public char readChar() throws IOException
readChar
in interface DataInput
IOException
public final char readCharLE() throws IOException
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.
EOFException
- if this stream reaches the end before reading
two bytes.
IOException
- if an I/O error occurs.public int readInt() throws IOException
readInt
in interface DataInput
IOException
public final int readIntLE() throws IOException
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.
int
.
EOFException
- if this stream reaches the end before reading
four bytes.
IOException
- if an I/O error occurs.public final long readUnsignedInt() throws IOException
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.
long
.
EOFException
- if this stream reaches the end before reading
four bytes.
IOException
- if an I/O error occurs.public final long readUnsignedIntLE() throws IOException
IOException
public long readLong() throws IOException
readLong
in interface DataInput
IOException
public final long readLongLE() throws IOException
IOException
public float readFloat() throws IOException
readFloat
in interface DataInput
IOException
public final float readFloatLE() throws IOException
IOException
public double readDouble() throws IOException
readDouble
in interface DataInput
IOException
public final double readDoubleLE() throws IOException
IOException
public String readLine() throws IOException
readLine
in interface DataInput
IOException
public String readUTF() throws IOException
readUTF
in interface DataInput
IOException
public long getStartOffset()
public void setStartOffset(long startOffset)
startOffset
- New value of property startOffset.public ByteBuffer getNioByteBuffer() throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |