org.apache.commons.compress.utils

## Class BoundedSeekableByteChannelInputStream

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

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class BoundedSeekableByteChannelInputStream
      extends BoundedArchiveInputStream

  InputStream that delegates requests to the underlying SeekableByteChannel, making sure that only bytes from a certain range can be read.
  Since:
    1.21
  This class is thread-safe

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BoundedSeekableByteChannelInputStream(long start, long remaining, SeekableByteChannel channel)` Create a bounded stream on the underlying `SeekableByteChannel`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected int` | `read(long pos, ByteBuffer buf)` Read content of the stream into a `ByteBuffer`.

    - ### Methods inherited from class org.apache.commons.compress.utils.BoundedArchiveInputStream

      `read, read`

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

    - #### BoundedSeekableByteChannelInputStream

          public BoundedSeekableByteChannelInputStream(long start,
                                                       long remaining,
                                                       SeekableByteChannel channel)

      Create a bounded stream on the underlying `SeekableByteChannel`
      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
        `channel` - Channel which the reads will be delegated to

  - ### Method Detail

    - #### read

          protected int read(long pos,
                             ByteBuffer buf)
                      throws IOException

      Description copied from class: `BoundedArchiveInputStream`
      Read content of the stream into a `ByteBuffer`.
      Specified by:
        `read` in class `BoundedArchiveInputStream`
      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–2020 The Apache Software Foundation. All rights reserved.