org.archive.io
Class BufferedSeekInputStream

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

public class BufferedSeekInputStream
extends SeekInputStream

Buffers data from some other SeekInputStream.

Author:
pjack

Constructor Summary
BufferedSeekInputStream(SeekInputStream input, int capacity)
          Constructor.
 
Method Summary
 void close()
          Close the stream, including the wrapped input stream.
 long position()
          Returns the stream's current position.
 void position(long p)
          Seeks to the given position.
 int read()
           
 int read(byte[] buf)
           
 int read(byte[] buf, int ofs, int len)
           
 long skip(long c)
           
 
Methods inherited from class org.archive.io.SeekInputStream
mark, markSupported, reset
 
Methods inherited from class java.io.InputStream
available
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedSeekInputStream

public BufferedSeekInputStream(SeekInputStream input,
                               int capacity)
                        throws java.io.IOException
Constructor.

Parameters:
input - the underlying input stream
capacity - the size of the buffer
Throws:
java.io.IOException - if an IO occurs filling the first buffer
Method Detail

read

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

read

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

read

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

skip

public long skip(long c)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

position

public long position()
              throws java.io.IOException
Returns the stream's current position.

Returns:
the current position
Throws:
java.io.IOException

position

public void position(long p)
              throws java.io.IOException
Seeks to the given position. This method avoids re-filling the buffer if at all possible.

Parameters:
p - the position to set
Throws:
java.io.IOException - if an IO error occurs

close

public void close()
           throws java.io.IOException
Close the stream, including the wrapped input stream.

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


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