Class BoundedInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.utils.BoundedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
A stream that limits reading from a wrapped stream to a given number of bytes.
- Since:
- 1.6
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBoundedInputStream(InputStream in, long size) Creates the stream that will at most read the given amount of bytes from the given stream. -
Method Summary
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Field Details
-
in
-
bytesRemaining
private long bytesRemaining
-
-
Constructor Details
-
BoundedInputStream
Creates the stream that will at most read the given amount of bytes from the given stream.- Parameters:
in- the stream to read fromsize- the maximum amount of bytes to read
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException- Since:
- 1.20
-
getBytesRemaining
public long getBytesRemaining()- Returns:
- bytes remaining to read
- Since:
- 1.21
-