Package org.apache.commons.compress.utils

# Class BoundedArchiveInputStream

java.lang.Object
java.io.InputStream
org.apache.commons.compress.utils.BoundedArchiveInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

Direct Known Subclasses:
  `BoundedSeekableByteChannelInputStream`

public abstract class BoundedArchiveInputStream extends InputStream
NIO backed bounded input stream for reading a predefined amount of data from.

Since:
  1.21
This class is thread-safe
  this base class is thread safe but implementations must not be.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BoundedArchiveInputStream(long start, long remaining)`
  Create a new bounded input stream.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `read()`
  `int`
  `read(byte[] b, int off, int len)`
  `protected abstract int`
  `read(long pos, ByteBuffer buf)`
  Read content of the stream into a `ByteBuffer`.

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

  `available, close, mark, markSupported, read, reset, skip`

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

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

- ## Constructor Details

  - ### BoundedArchiveInputStream

    public BoundedArchiveInputStream(long start, long remaining)
    Create a new bounded input stream.
    Parameters:
      `start` - position in the stream from where the reading of this bounded stream starts.
      `remaining` - amount of bytes which are allowed to read from the bounded stream.

- ## Method Details

  - ### read

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

  - ### read

    public int read(byte[] b, int off, int len) throws IOException
    Overrides:
      `read` in class `InputStream`
    Throws:
      `IOException`

  - ### read

    protected abstract int read(long pos, ByteBuffer buf) throws IOException
    Read content of the stream into a `ByteBuffer`.
    Parameters:
      `pos` - position to start the read.
      `buf` - buffer to add the read content.
    Returns:
      number of read bytes.
    Throws:
      `IOException` - if I/O fails.