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 classRandomDataInputMemory.SeeakableByteArrayInputStreamclass which allows seeking over a ByteArrayInputStream
-
Field Summary
Fields Modifier and Type Field Description protected org.terrier.utility.io.RandomDataInputMemory.Seekablebufinput 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 bufferprotectedRandomDataInputMemory(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.Objectclone()voidclose()longgetFilePointer()Return the current position in the filelonglength()Returns the length of the filevoidreadFullyDirect(byte[] dst, long offset, int length)voidseek(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.IOExceptionConstruct 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.IOExceptionConstruct 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.IOExceptionReturn the current position in the file- Specified by:
getFilePointerin interfaceRandomDataInput- Throws:
java.io.IOException
-
length
public long length() throws java.io.IOExceptionReturns the length of the file- Specified by:
lengthin interfaceRandomDataInput- Throws:
java.io.IOException
-
seek
public void seek(long _pos) throws java.io.IOExceptionSeek to specified position in the file- Specified by:
seekin interfaceRandomDataInput- Throws:
java.io.IOException
-
readFullyDirect
public void readFullyDirect(byte[] dst, long offset, int length) throws java.io.IOException- Specified by:
readFullyDirectin interfaceRandomDataInput- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-