org.apache.commons.io.input

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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `END_OF_STREAM`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UnsynchronizedByteArrayInputStream(byte[] data)` Creates a new byte array input stream.
    `UnsynchronizedByteArrayInputStream(byte[] data, int offset)` Creates a new byte array input stream.
    `UnsynchronizedByteArrayInputStream(byte[] data, int offset, int length)` Creates a new byte array input stream.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()`
    `void` | `mark(int readlimit)`
    `boolean` | `markSupported()`
    `int` | `read()`
    `int` | `read(byte[] b)`
    `int` | `read(byte[] b, int off, int len)`
    `void` | `reset()`
    `long` | `skip(long n)`

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

      `close`

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

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

- - ### Field Detail

    - #### END_OF_STREAM

          public static final int END_OF_STREAM

      See Also:
        Constant Field Values

  - ### Constructor Detail

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

    - #### available

          public int available()

      Overrides:
        `available` in class `InputStream`

    - #### read

          public int read()

      Specified by:
        `read` in class `InputStream`

    - #### read

          public int read(byte[] b)

      Overrides:
        `read` in class `InputStream`

    - #### read

          public int read(byte[] b,
                          int off,
                          int len)

      Overrides:
        `read` in class `InputStream`

    - #### skip

          public long skip(long n)

      Overrides:
        `skip` in class `InputStream`

    - #### markSupported

          public boolean markSupported()

      Overrides:
        `markSupported` in class `InputStream`

    - #### mark

          public void mark(int readlimit)

      Overrides:
        `mark` in class `InputStream`

    - #### reset

          public void reset()

      Overrides:
        `reset` in class `InputStream`

Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.