-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public class ForwardReadableInputStream extends InputStream
java.io.InputStream wrapper that allows one to read the first X bytes of an InputStream on non markable streams, and use the wrapped stream as if it wasn't ever read. This class will throw if the wrapped stream does not have enough bytes to read the wanted bytes.
Calling read will be passed through the wrapped stream directly.
IMPORTANT NOTE: This class does NOT forward .close() to the wrapped input stream.
-
-
Field Summary
Fields Modifier and Type Field Description private Array<int>firstBytes
-
Constructor Summary
Constructors Constructor Description ForwardReadableInputStream(InputStream is, int bytesToRead)
-
Method Summary
Modifier and Type Method Description Array<int>getFirstBytes()Get the first bytes that have already been read intread()-
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ForwardReadableInputStream
ForwardReadableInputStream(InputStream is, int bytesToRead)
-
-
Method Detail
-
getFirstBytes
Array<int> getFirstBytes()
Get the first bytes that have already been read
-
read
int read()
-
-
-
-