org.archive.io
Class ArraySeekInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.archive.io.SeekInputStream
          extended by org.archive.io.ArraySeekInputStream
All Implemented Interfaces:
it.unimi.dsi.fastutil.io.RepositionableStream, java.io.Closeable

public class ArraySeekInputStream
extends SeekInputStream

A repositionable stream backed by an array.

Author:
pjack

Constructor Summary
ArraySeekInputStream(byte[] array)
          Constructor.
 
Method Summary
 long position()
          Returns the position of the stream.
 void position(long p)
          Repositions the stream.
 int read()
           
 int read(byte[] buf)
           
 int read(byte[] buf, int ofs, int len)
           
 
Methods inherited from class org.archive.io.SeekInputStream
mark, markSupported, reset
 
Methods inherited from class java.io.InputStream
available, close, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArraySeekInputStream

public ArraySeekInputStream(byte[] array)
Constructor. Note that changes to the given array will be reflected in the stream.

Parameters:
array - The array to read bytes from.
Method Detail

read

public int read()
Specified by:
read in class java.io.InputStream

read

public int read(byte[] buf,
                int ofs,
                int len)
Overrides:
read in class java.io.InputStream

read

public int read(byte[] buf)
Overrides:
read in class java.io.InputStream

position

public long position()
Returns the position of the stream.


position

public void position(long p)
              throws java.io.IOException
Repositions the stream.

Parameters:
p - the new position for the stream
Throws:
java.io.IOException - if the given position is out of bounds


Copyright © 2003-2011 Internet Archive. All Rights Reserved.