An interface into a data stream.
Method from org.apache.fontbox.ttf.TTFDataStream Detail: |
abstract public void close() throws IOException
Close the underlying resources. |
abstract public long getCurrentPosition() throws IOException
Get the current position in the stream. |
abstract public InputStream getOriginalData() throws IOException
This will get the original data file that was used for this
stream. |
abstract public int read() throws IOException
|
public byte[] read(int numberOfBytes) throws IOException {
byte[] data = new byte[ numberOfBytes ];
int amountRead = 0;
int totalAmountRead = 0;
while( (amountRead = read( data, totalAmountRead, numberOfBytes-totalAmountRead ) ) != -1 &&
totalAmountRead < numberOfBytes )
{
totalAmountRead += amountRead;
//read at most numberOfBytes bytes from the stream.
}
return data;
}
Read a specific number of bytes from the stream. |
abstract public int read(byte[] b,
int off,
int len) throws IOException
|
public float read32Fixed() throws IOException {
float retval = 0;
retval = readSignedShort();
retval += (readUnsignedShort()/65536);
return retval;
}
Read a 16.16 fixed value, where the first 16 bits are the decimal and the last
16 bits are the fraction. |
public Calendar readInternationalDate() throws IOException {
long secondsSince1904 = readLong();
GregorianCalendar cal = new GregorianCalendar( 1904, 0, 1 );
long millisFor1904 = cal.getTimeInMillis();
millisFor1904 += (secondsSince1904*1000);
cal.setTimeInMillis( millisFor1904 );
return cal;
}
Read an eight byte international date. |
abstract public long readLong() throws IOException
|
public int readSignedByte() throws IOException {
int signedByte = read();
return signedByte < 127 ? signedByte : signedByte-256;
}
|
abstract public short readSignedShort() throws IOException
|
public String readString(int length) throws IOException {
return readString( length, "ISO-8859-1" );
}
Read a fixed length ascii string. |
public String readString(int length,
String charset) throws IOException {
byte[] buffer = read( length );
return new String(buffer, charset);
}
Read a fixed length ascii string. |
public long readUnsignedInt() throws IOException {
long byte1 = read();
long byte2 = read();
long byte3 = read();
long byte4 = read();
if( byte4 < 0 )
{
throw new EOFException();
}
return (byte1 < < 24) + (byte2 < < 16) + (byte3 < < 8) + (byte4 < < 0);
}
Read an unsigned integer. |
abstract public int readUnsignedShort() throws IOException
|
public int[] readUnsignedShortArray(int length) throws IOException {
int[] array = new int[ length ];
for( int i=0; i< length; i++ )
{
array[i] = readUnsignedShort();
}
return array;
}
Read an unsigned short array. |
abstract public void seek(long pos) throws IOException
Seek into the datasource. |