Package org.apache.fontbox.ttf
Class MemoryTTFDataStream
- java.lang.Object
 - 
- org.apache.fontbox.ttf.TTFDataStream
 - 
- org.apache.fontbox.ttf.MemoryTTFDataStream
 
 
 
- 
- All Implemented Interfaces:
 java.io.Closeable,java.lang.AutoCloseable
public class MemoryTTFDataStream extends TTFDataStream
An interface into a data stream.- Author:
 - Ben Litchfield
 
 
- 
- 
Constructor Summary
Constructors Constructor Description MemoryTTFDataStream(java.io.InputStream is)Constructor from a stream. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying resources.longgetCurrentPosition()Get the current position in the stream.java.io.InputStreamgetOriginalData()This will get the original data file that was used for this stream.intread()Read an unsigned byte.intread(byte[] b, int off, int len)longreadLong()Read an unsigned byte.intreadSignedInt()Read a signed integer.shortreadSignedShort()Read an signed short.intreadUnsignedShort()Read an unsigned short.voidseek(long pos)Seek into the datasource.- 
Methods inherited from class org.apache.fontbox.ttf.TTFDataStream
read, read32Fixed, readInternationalDate, readSignedByte, readString, readString, readUnsignedByte, readUnsignedByteArray, readUnsignedInt, readUnsignedShortArray 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
MemoryTTFDataStream
public MemoryTTFDataStream(java.io.InputStream is) throws java.io.IOExceptionConstructor from a stream.- Parameters:
 is- The stream to read from. It will be closed by this method.- Throws:
 java.io.IOException- If an error occurs while reading from the stream.
 
 - 
 
- 
Method Detail
- 
readLong
public long readLong() throws java.io.IOExceptionRead an unsigned byte.- Specified by:
 readLongin classTTFDataStream- Returns:
 - An unsigned byte.
 - Throws:
 java.io.IOException- If there is an error reading the data.
 
- 
readSignedInt
public int readSignedInt() throws java.io.IOExceptionRead a signed integer.- Returns:
 - A signed integer.
 - Throws:
 java.io.IOException- If there is a problem reading the file.
 
- 
read
public int read() throws java.io.IOExceptionRead an unsigned byte.- Specified by:
 readin classTTFDataStream- Returns:
 - An unsigned byte.
 - Throws:
 java.io.IOException- If there is an error reading the data.
 
- 
readUnsignedShort
public int readUnsignedShort() throws java.io.IOExceptionRead an unsigned short.- Specified by:
 readUnsignedShortin classTTFDataStream- Returns:
 - An unsigned short.
 - Throws:
 java.io.IOException- If there is an error reading the data.
 
- 
readSignedShort
public short readSignedShort() throws java.io.IOExceptionRead an signed short.- Specified by:
 readSignedShortin classTTFDataStream- Returns:
 - An signed short.
 - Throws:
 java.io.IOException- If there is an error reading the data.
 
- 
close
public void close() throws java.io.IOExceptionClose the underlying resources.- Specified by:
 closein interfacejava.lang.AutoCloseable- Specified by:
 closein interfacejava.io.Closeable- Specified by:
 closein classTTFDataStream- Throws:
 java.io.IOException- If there is an error closing the resources.
 
- 
seek
public void seek(long pos) throws java.io.IOExceptionSeek into the datasource.- Specified by:
 seekin classTTFDataStream- Parameters:
 pos- The position to seek to.- Throws:
 java.io.IOException- If there is an error seeking to that position.
 
- 
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Specified by:
 readin classTTFDataStream- Parameters:
 b- The buffer to write to.off- The offset into the buffer.len- The length into the buffer.- Returns:
 - The number of bytes read, or -1 at the end of the stream
 - Throws:
 java.io.IOException- If there is an error reading from the stream.- See Also:
 InputStream.read( byte[], int, int )
 
- 
getCurrentPosition
public long getCurrentPosition() throws java.io.IOExceptionGet the current position in the stream.- Specified by:
 getCurrentPositionin classTTFDataStream- Returns:
 - The current position in the stream.
 - Throws:
 java.io.IOException- If an error occurs while reading the stream.
 
- 
getOriginalData
public java.io.InputStream getOriginalData() throws java.io.IOExceptionThis will get the original data file that was used for this stream.- Specified by:
 getOriginalDatain classTTFDataStream- Returns:
 - The data that was read from.
 - Throws:
 java.io.IOException- If there is an issue reading the data.
 
 - 
 
 -