Package org.terrier.utility.io
Class RandomDataInputMemory
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.DataInputStream
-
- org.terrier.utility.io.RandomDataInputMemory
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataInput
,java.lang.AutoCloseable
,java.lang.Cloneable
,RandomDataInput
public class RandomDataInputMemory extends java.io.DataInputStream implements RandomDataInput, java.lang.Cloneable
Implements a RandomDataInput backed by a byte[] rather than a file.- Since:
- 3.0
- Author:
- Craig Macdonald
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RandomDataInputMemory.SeeakableByteArrayInputStream
class which allows seeking over a ByteArrayInputStream
-
Field Summary
Fields Modifier and Type Field Description protected org.terrier.utility.io.RandomDataInputMemory.Seekable
buf
input stream to use
-
Constructor Summary
Constructors Modifier Constructor Description RandomDataInputMemory(byte[] b)
Construct a new RandomDataInputMemory object, backed by the specified bufferRandomDataInputMemory(java.io.DataInputStream in, long length)
Construct a new RandomDataInputMemory object, backed by the specified bufferprotected
RandomDataInputMemory(java.io.InputStream seekable)
RandomDataInputMemory(java.lang.String filename)
Construct a new RandomDataInputMemory object, backed by the specified file
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
void
close()
long
getFilePointer()
Return the current position in the filelong
length()
Returns the length of the filevoid
readFullyDirect(byte[] dst, long offset, int length)
void
seek(long _pos)
Seek to specified position in the file-
Methods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes
-
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, reset, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
RandomDataInputMemory
protected RandomDataInputMemory(java.io.InputStream seekable) throws java.io.IOException
- Throws:
java.io.IOException
-
RandomDataInputMemory
public RandomDataInputMemory(java.lang.String filename) throws java.io.IOException
Construct a new RandomDataInputMemory object, backed by the specified file- Throws:
java.io.IOException
-
RandomDataInputMemory
public RandomDataInputMemory(java.io.DataInputStream in, long length) throws java.io.IOException
Construct a new RandomDataInputMemory object, backed by the specified buffer- Throws:
java.io.IOException
-
RandomDataInputMemory
public RandomDataInputMemory(byte[] b)
Construct a new RandomDataInputMemory object, backed by the specified buffer
-
-
Method Detail
-
getFilePointer
public long getFilePointer() throws java.io.IOException
Return the current position in the file- Specified by:
getFilePointer
in interfaceRandomDataInput
- Throws:
java.io.IOException
-
length
public long length() throws java.io.IOException
Returns the length of the file- Specified by:
length
in interfaceRandomDataInput
- Throws:
java.io.IOException
-
seek
public void seek(long _pos) throws java.io.IOException
Seek to specified position in the file- Specified by:
seek
in interfaceRandomDataInput
- Throws:
java.io.IOException
-
readFullyDirect
public void readFullyDirect(byte[] dst, long offset, int length) throws java.io.IOException
- Specified by:
readFullyDirect
in interfaceRandomDataInput
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Overrides:
clone
in classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
-
-