org.terrier.utility.io
Class RandomDataInputMemory

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.io.DataInputStream
              extended by org.terrier.utility.io.RandomDataInputMemory
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput, 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

Field Summary
protected  org.terrier.utility.io.RandomDataInputMemory.Seekable buf
          input stream to use
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
  RandomDataInputMemory(byte[] b)
          Construct a new RandomDataInputMemory object, backed by the specified buffer
  RandomDataInputMemory(java.io.DataInputStream in, long length)
          Construct a new RandomDataInputMemory object, backed by the specified buffer
protected RandomDataInputMemory(java.io.InputStream seekable)
           
  RandomDataInputMemory(java.lang.String filename)
          Construct a new RandomDataInputMemory object, backed by the specified file
 
Method Summary
 java.lang.Object clone()
           
 void close()
          
 long getFilePointer()
          Return the current position in the file
 long length()
          Returns the length of the file
 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.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
 

Field Detail

buf

protected org.terrier.utility.io.RandomDataInputMemory.Seekable buf
input stream to use

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 interface RandomDataInput
Throws:
java.io.IOException

length

public long length()
            throws java.io.IOException
Returns the length of the file

Specified by:
length in interface RandomDataInput
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 interface RandomDataInput
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterInputStream
Throws:
java.io.IOException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException


Terrier 3.5. Copyright © 2004-2011 University of Glasgow