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 and Description
    `BoundedArchiveInputStream(long start, long remaining)` Create a new bounded input stream.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and 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 Detail

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

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

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