public class RandomAccessFileOrArray extends Object implements DataInput, Serializable
Modifier and Type | Field and Description |
---|---|
static boolean |
plainRandomAccess
When true the file access is not done through a memory mapped file.
|
Constructor and Description |
---|
RandomAccessFileOrArray(IRandomAccessSource byteSource)
Creates a RandomAccessFileOrArray that wraps the specified byte source.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying source.
|
IRandomAccessSource |
createSourceView()
Creates the view of the byte source of this object.
|
RandomAccessFileOrArray |
createView()
Creates an independent view of this object (with it's own file pointer and push back queue).
|
long |
getPosition()
Gets the current position of the source considering the pushed byte to the source.
|
long |
length()
Gets the total amount of bytes in the source.
|
void |
pushBack(byte b)
Pushes a byte back.
|
int |
read()
Reads a single byte
|
int |
read(byte[] b)
Reads the bytes to the buffer.
|
int |
read(byte[] b, int off, int len)
Reads the specified amount of bytes to the buffer applying the offset.
|
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.
|
String |
readString(int length, String encoding)
Reads a String from the font file as bytes using the given encoding.
|
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 |
seek(long pos)
Sets the current position in the source to the specified index.
|
long |
skip(long n)
Make an attempt to skip the specified amount of bytes in source.
|
int |
skipBytes(int n) |
public static boolean plainRandomAccess
public RandomAccessFileOrArray(IRandomAccessSource byteSource)
byteSource
- the byte source to wrap
public RandomAccessFileOrArray createView()
public IRandomAccessSource createSourceView()
public void pushBack(byte b)
b
- the byte to push
public int read() throws IOException
IOException
- in case of any reading error.
public int read(byte[] b, int off, int len) throws IOException
b
- destination buffer
off
- offset at which to start storing characters
len
- maximum number of characters to read
IOException
- in case of any I/O error
public int read(byte[] b) throws IOException
b
- the destination buffer
IOException
- in
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
n
- the number of bytes to skip
IOException
- in case of any I/O error
public int skipBytes(int n) throws IOException
skipBytes
in interface DataInput
IOException
public void close() throws IOException
IOException
public long length() throws IOException
IOException
public void seek(long pos) throws IOException
pos
- the position to set
IOException
public long getPosition() throws IOException
IOException
- in case of any I/O error.
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 String readString(int length, String encoding) throws IOException
String
from the font file as bytes using the given encoding.
length
- the length of bytes to read
encoding
- the given encoding
String
read
IOException
- the font file could not be read
Copyright © 1998–2017 iText Group NV. All rights reserved.