public class RepositionableInputStream
extends java.io.BufferedInputStream
implements it.unimi.dsi.fastutil.io.RepositionableStream
InputStream to make a primitive Repositionable
stream. Uses a BufferedInputStream. Calls mark on every read so
we'll remember at least the last thing read (You can only backup on the
last thing read -- not last 2 or 3 things read). Used by
GzippedInputStream when reading streams over a network. Wraps a
HTTP, etc., stream so we can back it up if needs be after the
GZIP inflater has done a fill of its full buffer though it only needed
the first few bytes to finish decompressing the current GZIP member.
TODO: More robust implementation. Tried to use the it.unimi.dsi.io FastBufferdInputStream but relies on FileChannel ByteBuffers and if not present -- as would be the case reading from a network stream, the main application for this instance -- then it expects the underlying stream implements RepositionableStream interface so chicken or egg problem.
| Constructor and Description |
|---|
RepositionableInputStream(java.io.InputStream in) |
RepositionableInputStream(java.io.InputStream in,
int size) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
isMarked() |
void |
mark(int readlimit) |
long |
position() |
void |
position(long offset) |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int offset,
int ct) |
void |
reset() |
public RepositionableInputStream(java.io.InputStream in)
public RepositionableInputStream(java.io.InputStream in,
int size)
public int read(byte[] b)
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read(byte[] b,
int offset,
int ct)
throws java.io.IOException
read in class java.io.BufferedInputStreamjava.io.IOExceptionpublic int read()
throws java.io.IOException
read in class java.io.BufferedInputStreamjava.io.IOExceptionpublic void position(long offset)
position in interface it.unimi.dsi.fastutil.io.RepositionableStreampublic void mark(int readlimit)
mark in class java.io.BufferedInputStreampublic void reset()
throws java.io.IOException
reset in class java.io.BufferedInputStreamjava.io.IOExceptionprotected boolean isMarked()
public long position()
position in interface it.unimi.dsi.fastutil.io.RepositionableStreamCopyright © 2019 The International Internet Preservation Consortium. All Rights Reserved.