public static interface Bitstream.ByteStream<T>
Modifier and Type | Method and Description |
---|---|
boolean |
canInput()
Return true if stream can handle input, i.e.
|
boolean |
canOutput()
Return true if stream can handle output, i.e.
|
void |
close()
Closing the underlying stream, implies
flush() . |
void |
flush()
Synchronizes all underlying
output stream operations, or do nothing. |
T |
getStream()
Returns the underlying stream
|
void |
mark(int readLimit)
Set
markpos to current position, allowing the stream to be reset() . |
long |
position()
Returns the byte position in the stream.
|
long |
position(long newPosition)
Sets this stream's position.
|
int |
read()
Reads one byte from the stream.
|
void |
reset()
Reset stream position to markpos as set via
mark(int) . |
void |
setStream(T stream)
Sets the underlying stream, without
close() ing the previous one. |
long |
skip(long n)
It is implementation dependent, whether backward skip giving a negative number is supported or not.
|
int |
write(byte val)
Writes one byte, to the stream.
|
T getStream()
void close() throws IOException
flush()
.
Implementation will null
the stream references,
hence setStream(Object)
must be called before re-using instance.
IOException
void flush() throws IOException
output stream
operations, or do nothing.IOException
boolean canInput()
read()
.boolean canOutput()
write(byte)
long position()
long position(long newPosition) throws UnsupportedOperationException, IllegalArgumentException
A set mark is cleared if > new position.
Returns Bitstream.EOS
is end-of-stream is reached,
otherwise the new position.
Known supporting implementation is Bitstream.ByteBufferStream
and Bitstream.ByteArrayStream
.
newPosition
- The new positive position.Bitstream.EOS
if end-of-stream is reached.UnsupportedOperationException
- if not supported, i.e. Bitstream.ByteInputStream
or Bitstream.ByteOutputStream
IllegalArgumentException
- If the newPosition
is negativelong skip(long n) throws IOException
n
- number of bytes to skipIOException
void mark(int readLimit) throws UnsupportedOperationException
markpos
to current position, allowing the stream to be reset()
.readlimit
- maximum number of bytes able to read before invalidating the markpos
.UnsupportedOperationException
- if not supported, i.e. if stream is not an input stream
.void reset() throws UnsupportedOperationException, IllegalStateException, IOException
mark(int)
.
markpos is kept, hence reset()
can be called multiple times.
UnsupportedOperationException
- if not supported, i.e. if stream is not an input stream
.IllegalStateException
- if markpos has not been set via mark(int)
or reset operation failed.IOException
- if reset operation failed.int read() throws UnsupportedOperationException, IOException
Returns Bitstream.EOS
is end-of-stream is reached,
otherwise the resulting value.
IOException
UnsupportedOperationException
- if not supported, i.e. if stream is not an input stream
.int write(byte val) throws UnsupportedOperationException, IOException
Returns Bitstream.EOS
is end-of-stream is reached,
otherwise the written value.
IOException
UnsupportedOperationException
- if not supported, i.e. if stream is not an output stream
.