Class ByteArrayStreamInput

java.lang.Object
java.io.InputStream
org.elasticsearch.common.io.stream.StreamInput
org.elasticsearch.common.io.stream.ByteArrayStreamInput
All Implemented Interfaces:
Closeable, AutoCloseable

public class ByteArrayStreamInput extends StreamInput
Resettable StreamInput that wraps a byte array. It is heavily inspired in Lucene's ByteArrayDataInput.
  • Constructor Details

    • ByteArrayStreamInput

      public ByteArrayStreamInput()
    • ByteArrayStreamInput

      public ByteArrayStreamInput(byte[] bytes)
  • Method Details

    • read

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

      public void reset(byte[] bytes)
    • getPosition

      public int getPosition()
    • setPosition

      public void setPosition(int pos)
    • reset

      public void reset(byte[] bytes, int offset, int len)
    • length

      public int length()
    • skipBytes

      public void skipBytes(long count)
    • close

      public void close()
      Description copied from class: StreamInput
      Closes the stream to further operations.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class StreamInput
    • available

      public int available()
      Specified by:
      available in class StreamInput
    • ensureCanReadBytes

      protected void ensureCanReadBytes(int length) throws EOFException
      Description copied from class: StreamInput
      This method throws an EOFException if the given number of bytes can not be read from the this stream. This method might be a no-op depending on the underlying implementation if the information of the remaining bytes is not present.
      Specified by:
      ensureCanReadBytes in class StreamInput
      Throws:
      EOFException
    • readByte

      public byte readByte()
      Description copied from class: StreamInput
      Reads and returns a single byte.
      Specified by:
      readByte in class StreamInput
    • readBytes

      public void readBytes(byte[] b, int offset, int len)
      Description copied from class: StreamInput
      Reads a specified number of bytes into an array at the specified offset.
      Specified by:
      readBytes in class StreamInput
      Parameters:
      b - the array to read bytes into
      offset - the offset in the array to start storing bytes
      len - the number of bytes to read