org.apache.hadoop.tools.rumen
Class RewindableInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.hadoop.tools.rumen.RewindableInputStream
All Implemented Interfaces:
Closeable

public class RewindableInputStream
extends InputStream

A simple wrapper class to make any input stream "rewindable". It could be made more memory efficient by grow the internal buffer adaptively.


Constructor Summary
RewindableInputStream(InputStream input)
          Constructor.
RewindableInputStream(InputStream input, int maxBytesToRemember)
          Constructor
 
Method Summary
 void close()
           
 int read()
           
 int read(byte[] buffer, int offset, int length)
           
 InputStream rewind()
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RewindableInputStream

public RewindableInputStream(InputStream input)
Constructor.

Parameters:
input -

RewindableInputStream

public RewindableInputStream(InputStream input,
                             int maxBytesToRemember)
Constructor

Parameters:
input - input stream.
maxBytesToRemember - Maximum number of bytes we need to remember at the beginning of the stream. If rewind() is called after so many bytes are read from the stream, rewind() would fail.
Method Detail

read

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

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

rewind

public InputStream rewind()
                   throws IOException
Throws:
IOException


Copyright © 2009 The Apache Software Foundation