public abstract class RandomAccessInputStream
extends java.io.InputStream
implements java.io.DataInput
Based on com.sun.media.jai.codec.SeekableStream.
To make it flexible, this class and any of its sub-class doesn't close the underlying stream. It's up to the underlying stream creator to close them. This ensures the actual stream out-lives the random stream itself in case we need to read more content from the underlying stream.
NOTE: for MemoryCacheRandomAccessInputStream, there is the risk of "over read" in which more bytes are cached in the buffer than actually needed. In this case, the underlying stream might not be usable anymore afterwards.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected java.io.InputStream |
src
The source stream.
|
| Modifier | Constructor and Description |
|---|---|
protected |
RandomAccessInputStream(java.io.InputStream src) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
ensureOpen()
Check to make sure that this stream has not been closed
|
protected void |
finalize() |
short |
getEndian() |
abstract long |
getStreamPointer() |
abstract int |
read() |
abstract int |
read(byte[] b,
int off,
int len) |
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
java.lang.String |
readLine()
Deprecated.
|
long |
readLong() |
float |
readS15Fixed16Number() |
short |
readShort() |
float |
readU16Fixed16Number() |
float |
readU8Fixed8Number() |
int |
readUnsignedByte() |
long |
readUnsignedInt() |
int |
readUnsignedShort() |
java.lang.String |
readUTF()
Due to the current implementation, writeUTF and readUTF are the
only methods which are machine or byte sequence independent as
they are actually both Motorola byte sequence under the hood.
|
abstract void |
seek(long loc) |
void |
setReadStrategy(ReadStrategy strategy) |
abstract void |
shallowClose()
Closes the RandomAccessInputStream and but keeps it's underlying stream open
|
int |
skipBytes(int n) |
protected java.io.InputStream src
protected boolean closed
protected RandomAccessInputStream(java.io.InputStream src)
public abstract void shallowClose()
throws java.io.IOException
java.io.IOExceptionprotected void ensureOpen()
throws java.io.IOException
java.io.IOExceptionprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic short getEndian()
public abstract long getStreamPointer()
public abstract int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic abstract int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic final boolean readBoolean()
throws java.io.IOException
readBoolean in interface java.io.DataInputjava.io.IOExceptionpublic final byte readByte()
throws java.io.IOException
readByte in interface java.io.DataInputjava.io.IOExceptionpublic final char readChar()
throws java.io.IOException
readChar in interface java.io.DataInputjava.io.IOExceptionpublic final double readDouble()
throws java.io.IOException
readDouble in interface java.io.DataInputjava.io.IOExceptionpublic final float readFloat()
throws java.io.IOException
readFloat in interface java.io.DataInputjava.io.IOExceptionpublic final void readFully(byte[] b)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic final void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic final int readInt()
throws java.io.IOException
readInt in interface java.io.DataInputjava.io.IOException@Deprecated
public final java.lang.String readLine()
throws java.io.IOException
readLine in interface java.io.DataInputjava.io.IOExceptionpublic final long readLong()
throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOExceptionpublic final float readS15Fixed16Number()
throws java.io.IOException
java.io.IOExceptionpublic final short readShort()
throws java.io.IOException
readShort in interface java.io.DataInputjava.io.IOExceptionpublic final float readU16Fixed16Number()
throws java.io.IOException
java.io.IOExceptionpublic final float readU8Fixed8Number()
throws java.io.IOException
java.io.IOExceptionpublic final int readUnsignedByte()
throws java.io.IOException
readUnsignedByte in interface java.io.DataInputjava.io.IOExceptionpublic final long readUnsignedInt()
throws java.io.IOException
java.io.IOExceptionpublic final int readUnsignedShort()
throws java.io.IOException
readUnsignedShort in interface java.io.DataInputjava.io.IOExceptionpublic final java.lang.String readUTF()
throws java.io.IOException
DataInputStream.readUTF(this);readUTF in interface java.io.DataInputjava.io.IOExceptionpublic abstract void seek(long loc)
throws java.io.IOException
java.io.IOExceptionpublic void setReadStrategy(ReadStrategy strategy)
public int skipBytes(int n)
throws java.io.IOException
skipBytes in interface java.io.DataInputjava.io.IOException