Class ByteBufferInputStream

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

@NotThreadSafe public final class ByteBufferInputStream extends InputStream
InputStream wrapped around a single ByteBuffer.
Author:
Philip Helger
  • Constructor Details

    • ByteBufferInputStream

      public ByteBufferInputStream(@Nonnull ByteBuffer aBuffer)
      Constructor
      Parameters:
      aBuffer - ByteBuffer to use. May not be null.
  • Method Details

    • isClosed

      public boolean isClosed()
    • getBuffer

      @Nullable public ByteBuffer getBuffer()
      Returns:
      The contained ByteBuffer. Handle with care! May be null if the stream is closed!
    • isAnythingAvailable

      public boolean isAnythingAvailable()
    • 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(@Nonnull byte[] aBuf)
      Overrides:
      read in class InputStream
    • read

      public int read(@Nonnull byte[] aBuffer, @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.