Class MultiByteBufferInputStream

java.lang.Object
java.io.InputStream
com.helger.base.io.stream.MultiByteBufferInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

@NotThreadSafe public final class MultiByteBufferInputStream extends InputStream
InputStream wrapped around one or more ByteBuffer objects.
Author:
Philip Helger
  • Constructor Details

    • MultiByteBufferInputStream

      public MultiByteBufferInputStream(@Nonempty @NonNull @Nonempty ByteBuffer... aBuffers)
      Constructor
      Parameters:
      aBuffers - Array of ByteBuffer. May neither be null nor empty and may not contain null elements.
  • Method Details

    • isClosed

      public boolean isClosed()
      Returns:
      true if this stream has been closed, false otherwise.
    • getAllBuffers

      @ReturnsMutableCopy public @NonNull ByteBuffer[] getAllBuffers()
      Returns:
      A copy of the array with the byte buffers. Never null.
    • isAnythingAvailable

      public boolean isAnythingAvailable()
      Returns:
      true if any byte buffer has at least one byte left.
    • getAvailable

      @Nonnegative public long getAvailable()
      Returns:
      The number of available bytes as a long. Always ≥ 0.
    • available

      @Nonnegative public int available()
      Overrides:
      available in class InputStream
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
    • mark

      public void mark(int nReadlimit)
      Overrides:
      mark in class InputStream
    • reset

      public void reset()
      Overrides:
      reset in class InputStream
    • markSupported

      public boolean markSupported()
      Overrides:
      markSupported in class InputStream
    • read

      public int read()
      Specified by:
      read in class InputStream
    • read

      public int read(byte @NonNull [] aBuf)
      Overrides:
      read in class InputStream
    • read

      public int read(byte @NonNull [] aBuf, @Nonnegative int nOfs, @Nonnegative int nLen)
      Overrides:
      read in class InputStream
    • skip

      @Nonnegative public long skip(long nBytesToSkip)
      Overrides:
      skip in class InputStream
    • read

      @Nonnegative public long read(@NonNull ByteBuffer aDestByteBuffer)
      Reads as much as possible into the destination buffer.
      Parameters:
      aDestByteBuffer - The destination byte buffer to use. May not be null.
      Returns:
      The number of bytes read. Always ≥ 0.