Class ByteBufferInputStream

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

    public final class ByteBufferInputStream
    extends java.io.InputStream
    This class is a customized input stream implementation which reads data from list of ByteBuffer. If the ByteBuffer is direct, it may reside outside the normal garbage-collected heap memory.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteBufferInputStream​(java.util.List<java.nio.ByteBuffer> bufList)
      Default Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.nio.ByteBuffer getBuffer()
      Return next non-empty @code{ByteBuffer}.
      int read()
      Reads data from the list of ByteBuffers.
      • Methods inherited from class java.io.InputStream

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

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

      • ByteBufferInputStream

        public ByteBufferInputStream​(java.util.List<java.nio.ByteBuffer> bufList)
        Default Constructor.
        Parameters:
        bufList - is the target data to read.
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        Reads data from the list of ByteBuffers.
        Specified by:
        read in class java.io.InputStream
        Returns:
        integer.
        Throws:
        java.io.IOException - exception.
      • getBuffer

        public java.nio.ByteBuffer getBuffer()
                                      throws java.io.IOException
        Return next non-empty @code{ByteBuffer}.
        Returns:
        ByteBuffer to write the data.
        Throws:
        java.io.IOException - when fail to retrieve buffer.