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
outputoperations only.
-
-
Constructor Summary
Constructors Constructor Description ByteOutputStream(OutputStream stream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanInput()Return true if stream can handle input, i.e.booleancanOutput()Return true if stream can handle output, i.e.voidclose()Closing the underlying stream, impliesBitstream.ByteStream.flush().voidflush()Synchronizes all underlyingoutput streamoperations, or do nothing.OutputStreamgetStream()Returns the underlying streamvoidmark(int readLimit)Setmarkposto current position, allowing the stream to beBitstream.ByteStream.reset().longposition()Returns the byte position in the stream.longposition(long newPosition)Sets this stream's position.intread()Reads one byte from the stream.voidreset()Reset stream position to markpos as set viaBitstream.ByteStream.mark(int).voidsetStream(OutputStream stream)Sets the underlying stream, withoutBitstream.ByteStream.close()ing the previous one.longskip(long n)It is implementation dependent, whether backward skip giving a negative number is supported or not.intwrite(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.ByteStreamSets the underlying stream, withoutBitstream.ByteStream.close()ing the previous one.- Specified by:
setStreamin interfaceBitstream.ByteStream<OutputStream>
-
close
public void close() throws IOExceptionDescription copied from interface:Bitstream.ByteStreamClosing the underlying stream, impliesBitstream.ByteStream.flush().Implementation will
nullthe stream references, henceBitstream.ByteStream.setStream(Object)must be called before re-using instance.- Specified by:
closein interfaceBitstream.ByteStream<OutputStream>- Throws:
IOException
-
flush
public void flush() throws IOExceptionDescription copied from interface:Bitstream.ByteStreamSynchronizes all underlyingoutput streamoperations, or do nothing.- Specified by:
flushin interfaceBitstream.ByteStream<OutputStream>- Throws:
IOException
-
canInput
public boolean canInput()
Description copied from interface:Bitstream.ByteStreamReturn true if stream can handle input, i.e.Bitstream.ByteStream.read().- Specified by:
canInputin interfaceBitstream.ByteStream<OutputStream>
-
canOutput
public boolean canOutput()
Description copied from interface:Bitstream.ByteStreamReturn true if stream can handle output, i.e.Bitstream.ByteStream.write(byte)- Specified by:
canOutputin interfaceBitstream.ByteStream<OutputStream>
-
position
public long position()
Description copied from interface:Bitstream.ByteStreamReturns the byte position in the stream.- Specified by:
positionin interfaceBitstream.ByteStream<OutputStream>
-
position
public long position(long newPosition) throws UnsupportedOperationException, IllegalArgumentExceptionDescription copied from interface:Bitstream.ByteStreamSets this stream's position.A set mark is cleared if > new position.
Returns
Bitstream.EOSis end-of-stream is reached, otherwise the new position.Known supporting implementation is
Bitstream.ByteBufferStreamandBitstream.ByteArrayStream.- Specified by:
positionin interfaceBitstream.ByteStream<OutputStream>- Parameters:
newPosition- The new positive position.- Returns:
- The new set position or
Bitstream.EOSif end-of-stream is reached. - Throws:
UnsupportedOperationException- if not supported, i.e.Bitstream.ByteInputStreamorBitstream.ByteOutputStreamIllegalArgumentException- If thenewPositionis negative
-
skip
public long skip(long n) throws IOExceptionDescription copied from interface:Bitstream.ByteStreamIt is implementation dependent, whether backward skip giving a negative number is supported or not.- Specified by:
skipin 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.ByteStreamReturns the underlying stream- Specified by:
getStreamin interfaceBitstream.ByteStream<OutputStream>
-
mark
public void mark(int readLimit) throws UnsupportedOperationExceptionDescription copied from interface:Bitstream.ByteStreamSetmarkposto current position, allowing the stream to beBitstream.ByteStream.reset().- Specified by:
markin interfaceBitstream.ByteStream<OutputStream>- Throws:
UnsupportedOperationException- if not supported, i.e. if stream is not aninput stream.
-
reset
public void reset() throws UnsupportedOperationExceptionDescription copied from interface:Bitstream.ByteStreamReset stream position to markpos as set viaBitstream.ByteStream.mark(int).markpos is kept, hence
Bitstream.ByteStream.reset()can be called multiple times.- Specified by:
resetin interfaceBitstream.ByteStream<OutputStream>- Throws:
UnsupportedOperationException- if not supported, i.e. if stream is not aninput stream.
-
read
public int read() throws UnsupportedOperationExceptionDescription copied from interface:Bitstream.ByteStreamReads one byte from the stream.Returns
Bitstream.EOSis end-of-stream is reached, otherwise the resulting value.- Specified by:
readin interfaceBitstream.ByteStream<OutputStream>- Throws:
UnsupportedOperationException- if not supported, i.e. if stream is not aninput stream.
-
write
public int write(byte val) throws IOExceptionDescription copied from interface:Bitstream.ByteStreamWrites one byte, to the stream.Returns
Bitstream.EOSis end-of-stream is reached, otherwise the written value.- Specified by:
writein interfaceBitstream.ByteStream<OutputStream>- Throws:
IOException
-
-