Package com.jogamp.common.util
Class Bitstream.ByteOutputStream
- java.lang.Object
-
- com.jogamp.common.util.Bitstream.ByteOutputStream
-
- All Implemented Interfaces:
Bitstream.ByteStream<OutputStream>
public static class Bitstream.ByteOutputStream extends Object implements Bitstream.ByteStream<OutputStream>
Specificbyte stream
.Can handle
output
operations only.
-
-
Constructor Summary
Constructors Constructor Description ByteOutputStream(OutputStream stream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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, impliesBitstream.ByteStream.flush()
.void
flush()
Synchronizes all underlyingoutput stream
operations, or do nothing.OutputStream
getStream()
Returns the underlying streamvoid
mark(int readLimit)
Setmarkpos
to current position, allowing the stream to beBitstream.ByteStream.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 viaBitstream.ByteStream.mark(int)
.void
setStream(OutputStream stream)
Sets the underlying stream, withoutBitstream.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.
-
-
-
Constructor Detail
-
ByteOutputStream
public ByteOutputStream(OutputStream stream)
-
-
Method Detail
-
setStream
public void setStream(OutputStream stream)
Description copied from interface:Bitstream.ByteStream
Sets the underlying stream, withoutBitstream.ByteStream.close()
ing the previous one.- Specified by:
setStream
in interfaceBitstream.ByteStream<OutputStream>
-
close
public void close() throws IOException
Description copied from interface:Bitstream.ByteStream
Closing the underlying stream, impliesBitstream.ByteStream.flush()
.Implementation will
null
the stream references, henceBitstream.ByteStream.setStream(Object)
must be called before re-using instance.- Specified by:
close
in interfaceBitstream.ByteStream<OutputStream>
- Throws:
IOException
-
flush
public void flush() throws IOException
Description copied from interface:Bitstream.ByteStream
Synchronizes all underlyingoutput stream
operations, or do nothing.- Specified by:
flush
in interfaceBitstream.ByteStream<OutputStream>
- Throws:
IOException
-
canInput
public boolean canInput()
Description copied from interface:Bitstream.ByteStream
Return true if stream can handle input, i.e.Bitstream.ByteStream.read()
.- Specified by:
canInput
in interfaceBitstream.ByteStream<OutputStream>
-
canOutput
public boolean canOutput()
Description copied from interface:Bitstream.ByteStream
Return true if stream can handle output, i.e.Bitstream.ByteStream.write(byte)
- Specified by:
canOutput
in interfaceBitstream.ByteStream<OutputStream>
-
position
public long position()
Description copied from interface:Bitstream.ByteStream
Returns the byte position in the stream.- Specified by:
position
in interfaceBitstream.ByteStream<OutputStream>
-
position
public long position(long newPosition) throws UnsupportedOperationException, IllegalArgumentException
Description copied from interface:Bitstream.ByteStream
Sets this stream's position.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
andBitstream.ByteArrayStream
.- Specified by:
position
in interfaceBitstream.ByteStream<OutputStream>
- Parameters:
newPosition
- The new positive position.- Returns:
- The new set position or
Bitstream.EOS
if end-of-stream is reached. - Throws:
UnsupportedOperationException
- if not supported, i.e.Bitstream.ByteInputStream
orBitstream.ByteOutputStream
IllegalArgumentException
- If thenewPosition
is negative
-
skip
public long skip(long n) throws IOException
Description copied from interface:Bitstream.ByteStream
It is implementation dependent, whether backward skip giving a negative number is supported or not.- Specified by:
skip
in interfaceBitstream.ByteStream<OutputStream>
- Parameters:
n
- number of bytes to skip- Returns:
- actual skipped bytes
- Throws:
IOException
-
getStream
public OutputStream getStream()
Description copied from interface:Bitstream.ByteStream
Returns the underlying stream- Specified by:
getStream
in interfaceBitstream.ByteStream<OutputStream>
-
mark
public void mark(int readLimit) throws UnsupportedOperationException
Description copied from interface:Bitstream.ByteStream
Setmarkpos
to current position, allowing the stream to beBitstream.ByteStream.reset()
.- Specified by:
mark
in interfaceBitstream.ByteStream<OutputStream>
- Throws:
UnsupportedOperationException
- if not supported, i.e. if stream is not aninput stream
.
-
reset
public void reset() throws UnsupportedOperationException
Description copied from interface:Bitstream.ByteStream
Reset stream position to markpos as set viaBitstream.ByteStream.mark(int)
.markpos is kept, hence
Bitstream.ByteStream.reset()
can be called multiple times.- Specified by:
reset
in interfaceBitstream.ByteStream<OutputStream>
- Throws:
UnsupportedOperationException
- if not supported, i.e. if stream is not aninput stream
.
-
read
public int read() throws UnsupportedOperationException
Description copied from interface:Bitstream.ByteStream
Reads one byte from the stream.Returns
Bitstream.EOS
is end-of-stream is reached, otherwise the resulting value.- Specified by:
read
in interfaceBitstream.ByteStream<OutputStream>
- Throws:
UnsupportedOperationException
- if not supported, i.e. if stream is not aninput stream
.
-
write
public int write(byte val) throws IOException
Description copied from interface:Bitstream.ByteStream
Writes one byte, to the stream.Returns
Bitstream.EOS
is end-of-stream is reached, otherwise the written value.- Specified by:
write
in interfaceBitstream.ByteStream<OutputStream>
- Throws:
IOException
-
-