Seekable, Closeable, AutoCloseableFileCacheSeekableStream, FileSeekableStream, MemoryCacheSeekableStreampublic abstract class SeekableInputStream extends InputStream implements Seekable
InputStreams implementing the Seekable interface.
SeekableOutputStream| Modifier and Type | Field | Description |
|---|---|---|
protected Stack<Long> |
markedPositions |
| Constructor | Description |
|---|---|
SeekableInputStream() |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
checkOpen() |
|
void |
close() |
Closes the stream.
|
protected abstract void |
closeImpl() |
|
protected void |
finalize() |
Finalizes this object prior to garbage collection.
|
void |
flush() |
Discards the initial position of the stream prior to the current stream
position.
|
void |
flushBefore(long pPosition) |
Discards the initial portion of the stream prior to the indicated
postion.
|
protected abstract void |
flushBeforeImpl(long pPosition) |
Discards the initial portion of the stream prior to the indicated postion.
|
long |
getFlushedPosition() |
Returns the earliest position in the stream to which seeking may be
performed.
|
long |
getStreamPosition() |
Returns the current byte position of the stream.
|
void |
mark() |
Marks a position in the stream to be returned to by a subsequent call to
reset.
|
void |
mark(int pLimit) |
|
boolean |
markSupported() |
Returns
true, as marking is always supported. |
int |
read(byte[] pBytes) |
|
void |
reset() |
Returns the file pointer to its previous position,
at the time of the most recent unmatched call to mark.
|
void |
seek(long pPosition) |
Sets the current stream position to the desired location.
|
protected abstract void |
seekImpl(long pPosition) |
|
long |
skip(long pLength) |
Implemented using
seek(currentPos + pLength). |
available, read, read, readAllBytes, readNBytes, transferToclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisCached, isCachedFile, isCachedMemorypublic final int read(byte[] pBytes)
throws IOException
read in class InputStreamIOExceptionpublic final long skip(long pLength)
throws IOException
seek(currentPos + pLength).skip in class InputStreampLength - the number of bytes to skippLength)IOException - if an I/O exception occurs during skippublic final void mark(int pLimit)
mark in class InputStreampublic final boolean markSupported()
true, as marking is always supported.markSupported in class InputStreamtrue.public final void seek(long pPosition)
throws IOException
SeekableIndexOutOfBoundsException will be thrown if pPosition is smaller
than the flushed position (as returned by Seekable.getFlushedPosition()).
It is legal to seek past the end of the file; an EOFException
will be thrown only if a read is performed.seek in interface SeekablepPosition - a long containing the desired file pointer position.IOException - if any other I/O error occurs.protected abstract void seekImpl(long pPosition)
throws IOException
IOExceptionpublic final void mark()
SeekableInputStream, all Seekable
streams upport marking. Additionally, calls to mark and
reset may be nested arbitrarily.
Unlike the mark methods declared by the Reader or
InputStream
interfaces, no readLimit parameter is used. An arbitrary amount
of data may be read following the call to mark.public final void reset()
throws IOException
SeekableIOExceptionIOException will be thrown if the previous marked position
lies in the discarded portion of the stream.reset in interface Seekablereset in class InputStreamIOException - if an I/O error occurs.InputStream.reset()public final void flushBefore(long pPosition)
throws IOException
SeekableIndexOutOfBoundsException.
Calling flushBefore may allow classes implementing this
interface to free up resources such as memory or disk space that are
being used to store data from the stream.flushBefore in interface SeekablepPosition - a long containing the length of the file prefix that
may be flushed.IOException - if an I/O error occurs.protected abstract void flushBeforeImpl(long pPosition)
throws IOException
pPosition - the position to flush toIOException - if an I/O exception occurs during the flush operationflushBefore(long)public final void flush()
throws IOException
SeekableflushBefore(getStreamPosition()).flush in interface SeekableIOException - if an I/O error occurs.public final long getFlushedPosition()
throws IOException
SeekableflushBefore.getFlushedPosition in interface Seekablelong.IOException - if an I/O error occurs.public final long getStreamPosition()
throws IOException
SeekablegetStreamPosition in interface Seekablelong containing the position of the stream.IOException - if an I/O error occurs.protected final void checkOpen()
throws IOException
IOExceptionpublic final void close()
throws IOException
Seekableclose in interface AutoCloseableclose in interface Closeableclose in interface Seekableclose in class InputStreamIOException - if the stream can't be closed.protected abstract void closeImpl()
throws IOException
IOExceptionprotected void finalize()
throws Throwable
close method is called to close any open input
source. This method should not be called from application
code.Copyright © 2018. All rights reserved.