com.jogamp.common.util

## Interface Bitstream.ByteStream<T>

- All Known Implementing Classes:
    Bitstream.ByteArrayStream, Bitstream.ByteBufferStream, Bitstream.ByteInputStream, Bitstream.ByteOutputStream
  Enclosing class:
    Bitstream<T>

      public static interface Bitstream.ByteStream<T>

  General byte stream.

- - ### Method Summary

    Methods
    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.
    `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.

- - ### Method Detail

    - #### setStream

          void setStream(T stream)

      Sets the underlying stream, without `close()`ing the previous one.

    - #### getStream

          T getStream()

      Returns the underlying stream

    - #### close

          void close()
                     throws IOException

      Closing the underlying stream, implies `flush()`.

      Implementation will `null` the stream references, hence `setStream(Object)` must be called before re-using instance.

      Throws:
        `IOException`

    - #### flush

          void flush()
                     throws IOException

      Synchronizes all underlying `output stream` operations, or do nothing.
      Throws:
        `IOException`

    - #### canInput

          boolean canInput()

      Return true if stream can handle input, i.e. `read()`.

    - #### canOutput

          boolean canOutput()

      Return true if stream can handle output, i.e. `write(byte)`

    - #### position

          long position()

      Returns the byte position in the stream.

    - #### skip

          long skip(long n)
                    throws IOException

      It is implementation dependent, whether backward skip giving a negative number is supported or not.
      Parameters:
        `n` - number of bytes to skip
      Returns:
        actual skipped bytes
      Throws:
        `IOException`

    - #### mark

          void mark(int readLimit)
                    throws UnsupportedOperationException

      Set markpos to current position, allowing the stream to be `reset()`.
      Parameters:
        `readLimit` -
      Throws:
        `UnsupportedOperationException` - is not supported, i.e. if stream is not an `input stream`.

    - #### reset

          void reset()
                     throws UnsupportedOperationException,
                            IllegalStateException,
                            IOException

      Reset stream position to markpos as set via `mark(int)`.

      markpos is kept, hence `reset()` can be called multiple times.

      Throws:
        `UnsupportedOperationException` - is 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.

    - #### read

          int read()
                   throws UnsupportedOperationException,
                          IOException

      Reads one byte from the stream.

      Returns `Bitstream.EOS` is end-of-stream is reached, otherwise the resulting value.

      Throws:
        `IOException`
        `UnsupportedOperationException` - is not supported, i.e. if stream is not an `input stream`.

    - #### write

          int write(byte val)
                    throws UnsupportedOperationException,
                           IOException

      Writes one byte, to the stream.

      Returns `Bitstream.EOS` is end-of-stream is reached, otherwise the written value.

      Throws:
        `IOException`
        `UnsupportedOperationException` - is not supported, i.e. if stream is not an `output stream`.