Class ArchiveInputStream<E extends ArchiveEntry>
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.commons.compress.archivers.ArchiveInputStream<E>
-
- Type Parameters:
E
- The type ofArchiveEntry
produced.
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
ArArchiveInputStream
,ArjArchiveInputStream
,CpioArchiveInputStream
,DumpArchiveInputStream
,TarArchiveInputStream
,ZipArchiveInputStream
public abstract class ArchiveInputStream<E extends ArchiveEntry> extends java.io.FilterInputStream
Archive input streams MUST override theFilterInputStream.read(byte[], int, int)
- orread()
- 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 Constructor Description ArchiveInputStream()
Constructs a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
canReadEntryData(ArchiveEntry archiveEntry)
Whether this stream is able to read the given entry.long
getBytesRead()
Gets the current number of bytes read from this stream.java.nio.charset.Charset
getCharset()
Gets the Charest.int
getCount()
Deprecated.this method may yield wrong results for large archives, usegetBytesRead()
instead.abstract E
getNextEntry()
Gets the next Archive Entry in this Stream.void
mark(int readlimit)
Does nothing.boolean
markSupported()
Always returns false.int
read()
Reads a byte of data.void
reset()
Does nothing.
-
-
-
Method Detail
-
canReadEntryData
public boolean canReadEntryData(ArchiveEntry archiveEntry)
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()
Gets the current number of bytes read from this stream.- Returns:
- the number of read bytes
- Since:
- 1.1
-
getCharset
public java.nio.charset.Charset getCharset()
Gets the Charest.- Returns:
- the Charest.
-
getCount
@Deprecated public int getCount()
Deprecated.this method may yield wrong results for large archives, usegetBytesRead()
instead.Gets the current number of bytes read from this stream.- Returns:
- the number of read bytes
-
getNextEntry
public abstract E getNextEntry() throws java.io.IOException
Gets the next Archive Entry in this Stream.- Returns:
- the next entry, or
null
if there are no more entries - Throws:
java.io.IOException
- if the next entry could not be read
-
mark
public void mark(int readlimit)
Does nothing. TODO [COMPRESS-670] Support mark() and reset() in ArchiveInputStream.- Overrides:
mark
in classjava.io.FilterInputStream
- Parameters:
readlimit
- ignored.
-
markSupported
public boolean markSupported()
Always returns false. TODO [COMPRESS-670] Support mark() and reset() in ArchiveInputStream.- Overrides:
markSupported
in classjava.io.FilterInputStream
- Returns:
- Always returns false.
-
read
public int read() throws java.io.IOException
Reads a byte of data. This method will block until enough input is available. Simply calls theFilterInputStream.read(byte[], int, int)
method. MUST be overridden if theFilterInputStream.read(byte[], int, int)
method is not overridden; may be overridden otherwise.- Overrides:
read
in classjava.io.FilterInputStream
- Returns:
- the byte read, or -1 if end of input is reached
- Throws:
java.io.IOException
- if an I/O error has occurred
-
reset
public void reset() throws java.io.IOException
Does nothing. TODO [COMPRESS-670] Support mark() and reset() in ArchiveInputStream.- Overrides:
reset
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
- not thrown here but may be thrown from a subclass.
-
-