Class InputOutputByteStream


  • @NotThreadSafe
    public class InputOutputByteStream
    extends Object
    A byte buffer which supports both InputStream and OutputStream interfaces without needless copying of (potentially large) byte arrays. Not intended for multi-threaded access (no synchronization).
    • Method Detail

      • size

        public int size()
        How many bytes have been written to the byte buffer
        Returns:
      • outputStream

        public OutputStream outputStream()
        Return a new output stream backed by the byte buffer managed by this.
        Returns:
        Throws:
        IllegalStateException - if called after the mode has been flipped to read.
      • inputStream

        public InputStream inputStream()
        Provide a new InputStream with its own dedicated position starting at 0 offset
        Returns:
      • wrap

        public ByteBuffer wrap()
        Provides a wrapped version of the internal buffer.
        Returns:
        a read-only ByteBuffer.
      • reset

        public void reset()
        Reset the offset to make the buffer appear empty. Does not change the current length (capacity). Note that any streams currently being used to read the data will end.