ByteBufferInputStream (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.fs.store, class: ByteBufferInputStream

Package org.apache.hadoop.fs.store

# 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 Summary

  Constructors
  Constructor
  Description
  `ByteBufferInputStream(int size, ByteBuffer byteBuffer)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `available()`
  `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.
  `boolean`
  `hasRemaining()`
  Check if there is data left.
  `boolean`
  `isOpen()`
  Is the stream open?
  `void`
  `mark(int readlimit)`
  `boolean`
  `markSupported()`
  `int`
  `position()`
  Get the current buffer position.
  `int`
  `read()`
  `int`
  `read(byte[] b, int offset, int length)`
  Read in data.
  `void`
  `reset()`
  `long`
  `skip(long offset)`
  `String`
  `toString()`

  ### Methods inherited from class java.io.InputStream

  `nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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`