Class MultiByteBufferInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class MultiByteBufferInputStream
    extends java.io.InputStream
    Joins a list of byte buffers to make them appear as a single input stream.

    The reset method is supported, and always resets to restart the stream at the beginning of the first buffer, although markSupported() returns false for this class.

    • Constructor Summary

      Constructors 
      Constructor Description
      MultiByteBufferInputStream​(java.util.List<java.nio.ByteBuffer> initialBuffers)
      Initializes a MultiByteBufferInputStream using the provided byte buffers.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.util.List<java.nio.ByteBuffer> additionalBuffers)
      Adds additional byte buffers to this instance in a thread-safe manner.
      int read()
      Reads the next byte from the buffer.
      void reset()
      Resets the byte buffer.
      • Methods inherited from class java.io.InputStream

        available, close, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiByteBufferInputStream

        public MultiByteBufferInputStream​(java.util.List<java.nio.ByteBuffer> initialBuffers)
        Initializes a MultiByteBufferInputStream using the provided byte buffers.
        Parameters:
        initialBuffers - A list of ByteBuffers to use.
    • Method Detail

      • add

        public void add​(java.util.List<java.nio.ByteBuffer> additionalBuffers)
        Adds additional byte buffers to this instance in a thread-safe manner.
        Parameters:
        additionalBuffers - The additional ByteBuffers.
      • read

        public int read()
                 throws java.io.IOException
        Reads the next byte from the buffer.
        Specified by:
        read in class java.io.InputStream
        Returns:
        The next byte.
        Throws:
        java.io.IOException - Thrown when the byte buffers are exhausted.
      • reset

        public void reset()
        Resets the byte buffer.
        Overrides:
        reset in class java.io.InputStream