Class BoundedArchiveInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.utils.BoundedArchiveInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
BoundedSeekableByteChannelInputStream
,TarFile.BoundedTarEntryInputStream
,ZipFile.BoundedFileChannelInputStream
NIO backed bounded input stream for reading a predefined amount of data from.
- Since:
- 1.21
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBoundedArchiveInputStream
(long start, long remaining) Create a new bounded input stream. -
Method Summary
Modifier and TypeMethodDescriptionint
read()
int
read
(byte[] b, int off, int len) protected abstract int
read
(long pos, ByteBuffer buf) Read content of the stream into aByteBuffer
.Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, readAllBytes, readNBytes, reset, skip, transferTo
-
Field Details
-
end
private final long end -
singleByteBuffer
-
loc
private long loc
-
-
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
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
Read content of the stream into aByteBuffer
.- 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.
-