Class ArchiveInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.archivers.ArchiveInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
ArArchiveInputStream
,ArjArchiveInputStream
,CpioArchiveInputStream
,DumpArchiveInputStream
,TarArchiveInputStream
,ZipArchiveInputStream
Archive input streams MUST override the
InputStream.read(byte[], int, int)
- or read()
-
method so that reading from the stream generates EOF for the end of
data in each entry as well as at the end of the file proper.
The getNextEntry()
method is used to reset the input stream
ready for reading the data from the next entry.
The input stream classes must also implement a method with the signature:
public static boolean matches(byte[] signature, int length)which is used by the
ArchiveStreamFactory
to autodetect
the archive type from the first few bytes of a stream.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canReadEntryData
(ArchiveEntry archiveEntry) Whether this stream is able to read the given entry.long
Returns the current number of bytes read from this stream.int
getCount()
Deprecated.this method may yield wrong results for large archives, use #getBytesRead insteadabstract ArchiveEntry
Returns the next Archive Entry in this Stream.int
read()
Reads a byte of data.Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
ArchiveInputStream
public ArchiveInputStream()
-
-
Method Details
-
canReadEntryData
Whether this stream is able to read the given entry.Some archive formats support variants or details that are not supported (yet).
- Parameters:
archiveEntry
- the entry to test- Returns:
- This implementation always returns true.
- Since:
- 1.1
-
getBytesRead
public long getBytesRead()Returns the current number of bytes read from this stream.- Returns:
- the number of read bytes
- Since:
- 1.1
-
getCount
Deprecated.this method may yield wrong results for large archives, use #getBytesRead insteadReturns the current number of bytes read from this stream.- Returns:
- the number of read bytes
-
getNextEntry
Returns the next Archive Entry in this Stream.- Returns:
- the next entry,
or
null
if there are no more entries - Throws:
IOException
- if the next entry could not be read
-
read
Reads a byte of data. This method will block until enough input is available. Simply calls theInputStream.read(byte[], int, int)
method. MUST be overridden if theInputStream.read(byte[], int, int)
method is not overridden; may be overridden otherwise.- Specified by:
read
in classInputStream
- Returns:
- the byte read, or -1 if end of input is reached
- Throws:
IOException
- if an I/O error has occurred
-