public class RandomAccessInputStream
extends java.io.InputStream
implements java.io.DataInput, java.io.Closeable, com.esotericsoftware.kryo.KryoSerializable
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_BLOCK_SIZE
Block size to use when searching through the stream.
|
protected java.lang.String |
encoding |
protected java.lang.String |
file
The file name.
|
protected long |
length |
protected long |
markedPos |
protected static int |
MAX_OVERHEAD
Maximum size of the buffer used by the DataInputStream.
|
protected static int |
MAX_SEARCH_SIZE
Maximum number of bytes to search when searching through the stream.
|
protected IRandomAccess |
raf |
Constructor and Description |
---|
RandomAccessInputStream(byte[] array)
Constructs a random access stream around the given byte array.
|
RandomAccessInputStream(IRandomAccess handle)
Constructs a random access stream around the given handle.
|
RandomAccessInputStream(IRandomAccess handle,
java.lang.String file)
Constructs a random access stream around the given handle,
and with the associated file path.
|
RandomAccessInputStream(java.lang.String file)
Constructs a hybrid RandomAccessFile/DataInputStream
around the given file.
|
RandomAccessInputStream(java.lang.String file,
int bufferSize)
Constructs a hybrid RandomAccessFile/DataInputStream
around the given file.
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close()
Closes the streams.
|
java.lang.String |
findString(boolean saveString,
int blockSize,
java.lang.String... terminators)
Reads or skips a string ending with one of the given terminating
substrings, using the specified block size for buffering.
|
java.lang.String |
findString(boolean saveString,
java.lang.String... terminators)
Reads or skips a string ending with
one of the given terminating substrings.
|
java.lang.String |
findString(int blockSize,
java.lang.String... terminators)
Reads a string ending with one of the given terminating
substrings, using the specified block size for buffering.
|
java.lang.String |
findString(java.lang.String... terminators)
Reads a string ending with one of the given terminating substrings.
|
long |
getFilePointer()
Gets the current (absolute) file pointer.
|
boolean |
isLittleEndian()
Gets the endianness of the stream.
|
long |
length()
Gets the number of bytes in the file.
|
void |
mark(int readLimit) |
boolean |
markSupported() |
void |
order(boolean little)
Sets the endianness of the stream.
|
int |
read() |
int |
read(byte[] array)
Read bytes from the stream into the given array.
|
int |
read(byte[] array,
int offset,
int n)
Read n bytes from the stream into the given array at the specified offset.
|
int |
read(java.nio.ByteBuffer buf)
Read bytes from the stream into the given buffer.
|
int |
read(java.nio.ByteBuffer buf,
int offset,
int n)
Read n bytes from the stream into the given buffer at the specified offset.
|
void |
read(com.esotericsoftware.kryo.Kryo kryo,
com.esotericsoftware.kryo.io.Input in) |
boolean |
readBoolean()
Read an input byte and return true if the byte is nonzero.
|
byte |
readByte()
Read one byte and return it.
|
char |
readChar()
Read an input char.
|
java.lang.String |
readCString()
Read a string of arbitrary length, terminated by a null char.
|
double |
readDouble()
Read eight bytes and return a double value.
|
float |
readFloat()
Read four bytes and return a float value.
|
void |
readFully(byte[] array)
Read bytes from the stream into the given array.
|
void |
readFully(byte[] array,
int offset,
int n)
Read n bytes from the stream into the given array at the specified offset.
|
int |
readInt()
Read four input bytes and return an int value.
|
java.lang.String |
readLine()
Read the next line of text from the input stream.
|
long |
readLong()
Read eight input bytes and return a long value.
|
short |
readShort()
Read two input bytes and return a short value.
|
java.lang.String |
readString(int n)
Read a string of up to length n.
|
java.lang.String |
readString(java.lang.String lastChars)
Reads a string ending with one of the characters in the given string.
|
int |
readUnsignedByte()
Read an input byte and zero extend it appropriately.
|
int |
readUnsignedShort()
Read two bytes and return an int in the range 0 through 65535.
|
java.lang.String |
readUTF()
Read a string that has been encoded using a modified UTF-8 format.
|
void |
reset() |
void |
seek(long pos)
Seeks to the given offset within the stream.
|
void |
setEncoding(java.lang.String encoding)
Sets the native encoding of the stream.
|
void |
setLength(long newLength)
Sets the length of the stream.
|
int |
skipBytes(int n)
Skip n bytes within the stream.
|
void |
write(com.esotericsoftware.kryo.Kryo kryo,
com.esotericsoftware.kryo.io.Output out) |
protected static final int MAX_OVERHEAD
protected static final int DEFAULT_BLOCK_SIZE
protected static final int MAX_SEARCH_SIZE
protected IRandomAccess raf
protected java.lang.String file
protected long length
protected long markedPos
protected java.lang.String encoding
public RandomAccessInputStream(java.lang.String file) throws java.io.IOException
java.io.IOException
public RandomAccessInputStream(java.lang.String file, int bufferSize) throws java.io.IOException
java.io.IOException
public RandomAccessInputStream(IRandomAccess handle) throws java.io.IOException
java.io.IOException
public RandomAccessInputStream(IRandomAccess handle, java.lang.String file) throws java.io.IOException
java.io.IOException
public RandomAccessInputStream(byte[] array) throws java.io.IOException
java.io.IOException
public void setEncoding(java.lang.String encoding)
Constants.ENCODING
public void seek(long pos) throws java.io.IOException
java.io.IOException
public long length() throws java.io.IOException
java.io.IOException
public void setLength(long newLength) throws java.io.IOException
java.io.IOException
public long getFilePointer() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public void order(boolean little)
public boolean isLittleEndian()
public java.lang.String readString(java.lang.String lastChars) throws java.io.IOException
java.io.IOException
findString(String...)
public java.lang.String findString(java.lang.String... terminators) throws java.io.IOException
terminators
- The strings for which to search.java.io.IOException
public java.lang.String findString(boolean saveString, java.lang.String... terminators) throws java.io.IOException
saveString
- Whether to collect the string from the current file
pointer to the terminating bytes, and return it. If false, returns null.terminators
- The strings for which to search.java.io.IOException
- If saveString flag is set
and the maximum search length (512 MB) is exceeded.public java.lang.String findString(int blockSize, java.lang.String... terminators) throws java.io.IOException
blockSize
- The block size to use when reading bytes in chunks.terminators
- The strings for which to search.java.io.IOException
public java.lang.String findString(boolean saveString, int blockSize, java.lang.String... terminators) throws java.io.IOException
saveString
- Whether to collect the string from the current file
pointer to the terminating bytes, and return it. If false, returns null.blockSize
- The block size to use when reading bytes in chunks.terminators
- The strings for which to search.java.io.IOException
- If saveString flag is set
and the maximum search length (512 MB) is exceeded.public boolean readBoolean() throws java.io.IOException
readBoolean
in interface java.io.DataInput
java.io.IOException
public byte readByte() throws java.io.IOException
readByte
in interface java.io.DataInput
java.io.IOException
public char readChar() throws java.io.IOException
readChar
in interface java.io.DataInput
java.io.IOException
public double readDouble() throws java.io.IOException
readDouble
in interface java.io.DataInput
java.io.IOException
public float readFloat() throws java.io.IOException
readFloat
in interface java.io.DataInput
java.io.IOException
public int readInt() throws java.io.IOException
readInt
in interface java.io.DataInput
java.io.IOException
public java.lang.String readLine() throws java.io.IOException
readLine
in interface java.io.DataInput
java.io.IOException
public java.lang.String readCString() throws java.io.IOException
java.io.IOException
public java.lang.String readString(int n) throws java.io.IOException
java.io.IOException
public long readLong() throws java.io.IOException
readLong
in interface java.io.DataInput
java.io.IOException
public short readShort() throws java.io.IOException
readShort
in interface java.io.DataInput
java.io.IOException
public int readUnsignedByte() throws java.io.IOException
readUnsignedByte
in interface java.io.DataInput
java.io.IOException
public int readUnsignedShort() throws java.io.IOException
readUnsignedShort
in interface java.io.DataInput
java.io.IOException
public java.lang.String readUTF() throws java.io.IOException
readUTF
in interface java.io.DataInput
java.io.IOException
public int skipBytes(int n) throws java.io.IOException
skipBytes
in interface java.io.DataInput
java.io.IOException
public int read(byte[] array) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] array, int offset, int n) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(java.nio.ByteBuffer buf) throws java.io.IOException
java.io.IOException
public int read(java.nio.ByteBuffer buf, int offset, int n) throws java.io.IOException
java.io.IOException
public void readFully(byte[] array) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
public void readFully(byte[] array, int offset, int n) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void mark(int readLimit)
mark
in class java.io.InputStream
public boolean markSupported()
markSupported
in class java.io.InputStream
public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input in)
read
in interface com.esotericsoftware.kryo.KryoSerializable
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output out)
write
in interface com.esotericsoftware.kryo.KryoSerializable
Copyright © 2014 Open Microscopy Environment