Class BoundedInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
kala.compress.utils.BoundedInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class BoundedInputStream extends FilterInputStream
A stream that limits reading from a wrapped stream to a given number of bytes.
Since:
1.6
  • Field Details

    • count

      private long count
      The current count of bytes counted.
    • maxCount

      private final long maxCount
      The max count of bytes to read.
    • propagateClose

      private final boolean propagateClose
      Flag if close should be propagated.
    • mark

      private long mark
      The current mark.
  • Constructor Details

    • BoundedInputStream

      public BoundedInputStream(InputStream in, long maxCount)
      Creates the stream that will at most read the given amount of bytes from the given stream.
      Parameters:
      in - the stream to read from
      maxCount - the maximum amount of bytes to read
    • BoundedInputStream

      public BoundedInputStream(InputStream in, long maxCount, boolean propagateClose)
      Creates the stream that will at most read the given amount of bytes from the given stream.
      Parameters:
      in - the stream to read from
      maxCount - the maximum amount of bytes to read
      propagateClose - true if calling close() propagates to the close() method of the underlying stream or false if it does not.
      Since:
      1.27.1-0
  • Method Details