Class BoundedArchiveInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.compress.utils.BoundedArchiveInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
BoundedSeekableByteChannelInputStream,TarFile.BoundedTarEntryInputStream,ZipFile.BoundedFileChannelInputStream
public abstract class BoundedArchiveInputStream extends java.io.InputStreamNIO backed bounded input stream for reading a predefined amount of data from.- Since:
- 1.21
-
-
Field Summary
Fields Modifier and Type Field Description private longendprivate longlocprivate java.nio.ByteBuffersingleByteBuffer
-
Constructor Summary
Constructors Constructor 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 Description intread()intread(byte[] b, int off, int len)protected abstract intread(long pos, java.nio.ByteBuffer buf)Read content of the stream into aByteBuffer.
-
-
-
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 java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
protected abstract int read(long pos, java.nio.ByteBuffer buf) throws java.io.IOExceptionRead 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:
java.io.IOException- if I/O fails.
-
-