Class FastByteArrayInputStream

All Implemented Interfaces:
MeasurableStream, RepositionableStream, Closeable, DataInput, ObjectInput, AutoCloseable

public class FastByteArrayInputStream extends MeasurableInputStream implements RepositionableStream, ObjectInput
Simple, fast and repositionable byte-array input stream with built-in ObjectInput support.

Warning: this class implements the correct semantics of read(byte[], int, int) as described in InputStream. The implementation given in ByteArrayInputStream is broken, but it will never be fixed because it's too late.

Author:
Sebastiano Vigna
  • Field Details

    • array

      public byte[] array
      The array backing the input stream.
    • offset

      public int offset
      The first valid entry.
    • length

      public int length
      The number of valid bytes in array starting from offset.
  • Constructor Details

    • FastByteArrayInputStream

      public FastByteArrayInputStream(byte[] array, int offset, int length)
      Creates a new array input stream using a given array fragment.
      Parameters:
      array - the backing array.
      offset - the first valid entry of the array.
      length - the number of valid bytes.
    • FastByteArrayInputStream

      public FastByteArrayInputStream(byte[] array)
      Creates a new array input stream using a given array.
      Parameters:
      array - the backing array.
  • Method Details