public abstract class SeekableOutputStream extends OutputStream implements Seekable
OutputStream
s implementing the
Seekable
interface.
SeekableInputStream
Modifier and Type | Field and Description |
---|---|
protected Stack<Long> |
markedPositions |
Constructor and Description |
---|
SeekableOutputStream() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkOpen() |
void |
close()
Closes the stream.
|
protected abstract void |
closeImpl() |
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) |
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 |
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) |
void |
write(byte[] pBytes) |
write, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isCached, isCachedFile, isCachedMemory
public final void write(byte[] pBytes) throws IOException
write
in class OutputStream
IOException
public final void seek(long pPosition) throws IOException
Seekable
IndexOutOfBoundsException
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 Seekable
pPosition
- a long containing the desired file pointer position.IOException
- if any other I/O error occurs.protected abstract void seekImpl(long pPosition) throws IOException
IOException
public final void mark()
Seekable
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
.public final void reset() throws IOException
Seekable
IOException
IOException
will be thrown if the previous marked position
lies in the discarded portion of the stream.reset
in interface Seekable
IOException
- if an I/O error occurs.InputStream.reset()
public final void flushBefore(long pPosition) throws IOException
Seekable
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.flushBefore
in interface Seekable
pPosition
- 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
IOException
public final void flush() throws IOException
Seekable
flushBefore(getStreamPosition())
.flush
in interface Seekable
flush
in interface Flushable
flush
in class OutputStream
IOException
- if an I/O error occurs.public final long getFlushedPosition() throws IOException
Seekable
flushBefore
.getFlushedPosition
in interface Seekable
long
.IOException
- if an I/O error occurs.public final long getStreamPosition() throws IOException
Seekable
getStreamPosition
in interface Seekable
long
containing the position of the stream.IOException
- if an I/O error occurs.protected final void checkOpen() throws IOException
IOException
public final void close() throws IOException
Seekable
close
in interface Seekable
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
- if the stream can't be closed.protected abstract void closeImpl() throws IOException
IOException
Copyright © 2017. All rights reserved.