public static class Bitstream.ByteOutputStream extends Object implements Bitstream.ByteStream<OutputStream>
byte stream
.
Can handle output
operations only.
Constructor and Description |
---|
Bitstream.ByteOutputStream(OutputStream stream) |
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
Bitstream.ByteStream.flush() . |
void |
flush()
Synchronizes all underlying
output stream operations, or do nothing. |
OutputStream |
getStream()
Returns the underlying stream
|
void |
mark(int readLimit)
Set markpos to current position, allowing the stream to be
Bitstream.ByteStream.reset() . |
long |
position()
Returns the byte position in the stream.
|
int |
read()
Reads one byte from the stream.
|
void |
reset()
Reset stream position to markpos as set via
Bitstream.ByteStream.mark(int) . |
void |
setStream(OutputStream stream)
Sets the underlying stream, without
Bitstream.ByteStream.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.
|
public Bitstream.ByteOutputStream(OutputStream stream)
public void setStream(OutputStream stream)
Bitstream.ByteStream
Bitstream.ByteStream.close()
ing the previous one.setStream
in interface Bitstream.ByteStream<OutputStream>
public void close() throws IOException
Bitstream.ByteStream
Bitstream.ByteStream.flush()
.
Implementation will null
the stream references,
hence Bitstream.ByteStream.setStream(Object)
must be called before re-using instance.
close
in interface Bitstream.ByteStream<OutputStream>
IOException
public void flush() throws IOException
Bitstream.ByteStream
output stream
operations, or do nothing.flush
in interface Bitstream.ByteStream<OutputStream>
IOException
public boolean canInput()
Bitstream.ByteStream
Bitstream.ByteStream.read()
.canInput
in interface Bitstream.ByteStream<OutputStream>
public boolean canOutput()
Bitstream.ByteStream
Bitstream.ByteStream.write(byte)
canOutput
in interface Bitstream.ByteStream<OutputStream>
public long position()
Bitstream.ByteStream
position
in interface Bitstream.ByteStream<OutputStream>
public long skip(long n) throws IOException
Bitstream.ByteStream
skip
in interface Bitstream.ByteStream<OutputStream>
n
- number of bytes to skipIOException
public OutputStream getStream()
Bitstream.ByteStream
getStream
in interface Bitstream.ByteStream<OutputStream>
public void mark(int readLimit) throws UnsupportedOperationException
Bitstream.ByteStream
Bitstream.ByteStream.reset()
.mark
in interface Bitstream.ByteStream<OutputStream>
UnsupportedOperationException
- is not supported, i.e. if stream is not an input stream
.public void reset() throws UnsupportedOperationException
Bitstream.ByteStream
Bitstream.ByteStream.mark(int)
.
markpos is kept, hence Bitstream.ByteStream.reset()
can be called multiple times.
reset
in interface Bitstream.ByteStream<OutputStream>
UnsupportedOperationException
- is not supported, i.e. if stream is not an input stream
.public int read() throws UnsupportedOperationException
Bitstream.ByteStream
Returns Bitstream.EOS
is end-of-stream is reached,
otherwise the resulting value.
read
in interface Bitstream.ByteStream<OutputStream>
UnsupportedOperationException
- is not supported, i.e. if stream is not an input stream
.public int write(byte val) throws IOException
Bitstream.ByteStream
Returns Bitstream.EOS
is end-of-stream is reached,
otherwise the written value.
write
in interface Bitstream.ByteStream<OutputStream>
IOException