public interface Seekable
SeekableInputStream
,
SeekableOutputStream
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the stream.
|
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.
|
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.
|
boolean |
isCached()
Returns true if this
Seekable stream caches data itself in order
to allow seeking backwards. |
boolean |
isCachedFile()
Returns true if this
Seekable stream caches data itself in
order to allow seeking backwards, and the cache is kept in a
temporary file. |
boolean |
isCachedMemory()
Returns true if this
Seekable stream caches data itself in order
to allow seeking backwards, and the cache is kept in main memory. |
void |
mark()
Marks a position in the stream to be returned to by a subsequent call to
reset.
|
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.
|
long getStreamPosition() throws IOException
long
containing the position of the stream.IOException
- if an I/O error occurs.void seek(long pPosition) throws IOException
IndexOutOfBoundsException
will be thrown if pPosition is smaller
than the flushed position (as returned by getFlushedPosition()
).
It is legal to seek past the end of the file; an EOFException
will be thrown only if a read is performed.pPosition
- a long containing the desired file pointer position.IndexOutOfBoundsException
- if pPosition
is smaller than
the flushed position.IOException
- if any other I/O error occurs.void mark()
InputStream
, 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
.void reset() throws IOException
IOException
IOException
will be thrown if the previous marked position
lies in the discarded portion of the stream.IOException
- if an I/O error occurs.InputStream.reset()
void flushBefore(long pPosition) throws IOException
IndexOutOfBoundsException
.
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.pPosition
- a long containing the length of the file prefix that
may be flushed.IndexOutOfBoundsException
- if pPosition
lies in the
flushed portion of the stream or past the current stream position.IOException
- if an I/O error occurs.void flush() throws IOException
flushBefore(getStreamPosition())
.IOException
- if an I/O error occurs.long getFlushedPosition() throws IOException
flushBefore
.long
.IOException
- if an I/O error occurs.boolean isCached()
Seekable
stream caches data itself in order
to allow seeking backwards. Applications may consult this in order to
decide how frequently, or whether, to flush in order to conserve cache
resources.true
if this Seekable
caches data.isCachedMemory()
,
isCachedFile()
boolean isCachedMemory()
Seekable
stream caches data itself in order
to allow seeking backwards, and the cache is kept in main memory.
Applications may consult this in order to decide how frequently, or
whether, to flush in order to conserve cache resources.true
if this Seekable
caches data in main
memory.isCached()
,
isCachedFile()
boolean isCachedFile()
Seekable
stream caches data itself in
order to allow seeking backwards, and the cache is kept in a
temporary file.
Applications may consult this in order to decide how frequently,
or whether, to flush in order to conserve cache resources.true
if this Seekable
caches data in a
temporary file.isCached()
,
isCachedMemory()
void close() throws IOException
IOException
- if the stream can't be closed.Copyright © 2017. All rights reserved.