Class UnsynchronizedByteArrayInputStream

java.lang.Object
java.io.InputStream
org.apache.commons.io.input.UnsynchronizedByteArrayInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class UnsynchronizedByteArrayInputStream extends InputStream
This is an alternative to ByteArrayInputStream which removes the synchronization overhead for non-concurrent access; as such this class is not thread-safe.
Since:
2.7
  • Field Details

    • END_OF_STREAM

      public static final int END_OF_STREAM
      The end of stream marker.
      See Also:
    • data

      private final byte[] data
      The underlying data buffer.
    • eod

      private final int eod
      End Of Data. Similar to data.length, i.e. the last readable offset + 1.
    • offset

      private int offset
      Current offset in the data buffer.
    • markedOffset

      private int markedOffset
      The current mark (if any).
  • Constructor Details

    • UnsynchronizedByteArrayInputStream

      public UnsynchronizedByteArrayInputStream(byte[] data)
      Creates a new byte array input stream.
      Parameters:
      data - the buffer
    • UnsynchronizedByteArrayInputStream

      public UnsynchronizedByteArrayInputStream(byte[] data, int offset)
      Creates a new byte array input stream.
      Parameters:
      data - the buffer
      offset - the offset into the buffer
      Throws:
      IllegalArgumentException - if the offset is less than zero
    • UnsynchronizedByteArrayInputStream

      public UnsynchronizedByteArrayInputStream(byte[] data, int offset, int length)
      Creates a new byte array input stream.
      Parameters:
      data - the buffer
      offset - the offset into the buffer
      length - the length of the buffer
      Throws:
      IllegalArgumentException - if the offset or length less than zero
  • Method Details