Class ByteBufferInputStream

java.lang.Object
java.io.InputStream
org.apache.hadoop.fs.store.ByteBufferInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public final class ByteBufferInputStream extends InputStream
Provide an input stream from a byte buffer; supporting mark(int).
  • Constructor Details

    • ByteBufferInputStream

      public ByteBufferInputStream(int size, ByteBuffer byteBuffer)
  • Method Details

    • close

      public void close()
      After the stream is closed, set the local reference to the byte buffer to null; this guarantees that future attempts to use stream methods will fail.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
    • isOpen

      public boolean isOpen()
      Is the stream open?
      Returns:
      true if the stream has not been closed.
    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • skip

      public long skip(long offset) throws IOException
      Overrides:
      skip in class InputStream
      Throws:
      IOException
    • available

      public int available()
      Overrides:
      available in class InputStream
    • position

      public int position()
      Get the current buffer position.
      Returns:
      the buffer position
    • hasRemaining

      public boolean hasRemaining()
      Check if there is data left.
      Returns:
      true if there is data remaining in the buffer.
    • mark

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

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

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

      public int read(byte[] b, int offset, int length) throws IOException
      Read in data.
      Overrides:
      read in class InputStream
      Parameters:
      b - destination buffer.
      offset - offset within the buffer.
      length - length of bytes to read.
      Throws:
      EOFException - if the position is negative
      IndexOutOfBoundsException - if there isn't space for the amount of data requested.
      IllegalArgumentException - other arguments are invalid.
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object