public final class PositionalBufferedStream extends java.io.InputStream implements Positional
InputStream which performs it's own buffering, and keeps track of the position.
TODO: This class implements Positional, which in turn extends LocationAware, which requires preservation of
virtual file pointers on BGZF inputs. However, if the inputStream wrapped by this class is a BlockCompressedInputStream,
it violates that contract by wrapping the stream and returning positional file offsets instead.| Constructor and Description |
|---|
PositionalBufferedStream(java.io.InputStream is) |
PositionalBufferedStream(java.io.InputStream is,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
long |
getPosition()
The current offset, in bytes, of this stream/writer/file.
|
boolean |
isDone()
Is the stream done? Equivalent to ! hasNext() for an iterator?
|
static void |
main(java.lang.String[] args) |
int |
peek()
Return the next byte in the first, without actually reading it from the stream.
|
int |
read() |
int |
read(byte[] bytes) |
int |
read(byte[] bytes,
int start,
int len) |
long |
skip(long nBytes)
Skip the next nBytes in the stream.
|
public PositionalBufferedStream(java.io.InputStream is)
public PositionalBufferedStream(java.io.InputStream is,
int bufferSize)
public final long getPosition()
LocationAwaregetPosition in interface LocationAwarepublic final int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic final int read(byte[] bytes,
int start,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic final int read(byte[] bytes)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic final boolean isDone()
throws java.io.IOException
PositionalisDone in interface Positionaljava.io.IOExceptionpublic final int peek()
throws java.io.IOException
Positionalpeek in interface Positionaljava.io.IOExceptionpublic final long skip(long nBytes)
throws java.io.IOException
Positionalskip in interface Positionalskip in class java.io.InputStreamnBytes - to skip, must be >= 0java.io.IOExceptionpublic final void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreampublic static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception