org.archive.io
Class RepositionableInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
org.archive.io.RepositionableInputStream
- All Implemented Interfaces:
- it.unimi.dsi.fastutil.io.RepositionableStream, java.io.Closeable
public class RepositionableInputStream
- extends java.io.BufferedInputStream
- implements it.unimi.dsi.fastutil.io.RepositionableStream
Wrapper around an 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.
- Author:
- stack
Fields inherited from class java.io.BufferedInputStream |
buf, count, marklimit, markpos, pos |
Fields inherited from class java.io.FilterInputStream |
in |
Methods inherited from class java.io.BufferedInputStream |
available, close, markSupported, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RepositionableInputStream
public RepositionableInputStream(java.io.InputStream in)
RepositionableInputStream
public RepositionableInputStream(java.io.InputStream in,
int size)
read
public int read(byte[] b)
throws java.io.IOException
- Overrides:
read
in class java.io.FilterInputStream
- Throws:
java.io.IOException
read
public int read(byte[] b,
int offset,
int ct)
throws java.io.IOException
- Overrides:
read
in class java.io.BufferedInputStream
- Throws:
java.io.IOException
read
public int read()
throws java.io.IOException
- Overrides:
read
in class java.io.BufferedInputStream
- Throws:
java.io.IOException
position
public void position(long offset)
- Specified by:
position
in interface it.unimi.dsi.fastutil.io.RepositionableStream
mark
public void mark(int readlimit)
- Overrides:
mark
in class java.io.BufferedInputStream
reset
public void reset()
throws java.io.IOException
- Overrides:
reset
in class java.io.BufferedInputStream
- Throws:
java.io.IOException
isMarked
protected boolean isMarked()
position
public long position()
- Specified by:
position
in interface it.unimi.dsi.fastutil.io.RepositionableStream
Copyright © 2003-2011 Internet Archive. All Rights Reserved.