org.apache.hadoop.tools.rumen
Class RewindableInputStream
java.lang.Object
java.io.InputStream
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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
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