|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream org.apache.commons.compress.archivers.ArchiveInputStream org.apache.commons.compress.archivers.zip.ZipArchiveInputStream
public class ZipArchiveInputStream
Implements an input stream that can read Zip archives.
Note that ZipArchiveEntry.getSize()
may return -1 if the
DEFLATE algorithm is used, as the size information is not available
from the header.
The ZipFile
class is preferred when reading from files.
As of Apache Commons Compress it transparently supports Zip64 extensions and thus individual entries and archives larger than 4 GB or with more than 65536 entries.
ZipFile
Constructor Summary | |
---|---|
ZipArchiveInputStream(InputStream inputStream)
|
|
ZipArchiveInputStream(InputStream inputStream,
String encoding)
|
|
ZipArchiveInputStream(InputStream inputStream,
String encoding,
boolean useUnicodeExtraFields)
|
|
ZipArchiveInputStream(InputStream inputStream,
String encoding,
boolean useUnicodeExtraFields,
boolean allowStoredEntriesWithDataDescriptor)
|
Method Summary | |
---|---|
boolean |
canReadEntryData(ArchiveEntry ae)
Whether this class is able to read the given entry. |
void |
close()
|
ArchiveEntry |
getNextEntry()
Returns the next Archive Entry in this Stream. |
ZipArchiveEntry |
getNextZipEntry()
|
static boolean |
matches(byte[] signature,
int length)
Checks if the signature matches what is expected for a zip file. |
int |
read(byte[] buffer,
int start,
int length)
|
long |
skip(long value)
Skips over and discards value bytes of data from this input stream. |
Methods inherited from class org.apache.commons.compress.archivers.ArchiveInputStream |
---|
count, count, getBytesRead, getCount, pushedBackBytes, read |
Methods inherited from class java.io.InputStream |
---|
available, mark, markSupported, read, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ZipArchiveInputStream(InputStream inputStream)
public ZipArchiveInputStream(InputStream inputStream, String encoding)
encoding
- the encoding to use for file names, use null
for the platform's default encodingpublic ZipArchiveInputStream(InputStream inputStream, String encoding, boolean useUnicodeExtraFields)
encoding
- the encoding to use for file names, use null
for the platform's default encodinguseUnicodeExtraFields
- whether to use InfoZIP Unicode
Extra Fields (if present) to set the file names.public ZipArchiveInputStream(InputStream inputStream, String encoding, boolean useUnicodeExtraFields, boolean allowStoredEntriesWithDataDescriptor)
encoding
- the encoding to use for file names, use null
for the platform's default encodinguseUnicodeExtraFields
- whether to use InfoZIP Unicode
Extra Fields (if present) to set the file names.allowStoredEntriesWithDataDescriptor
- whether the stream
will try to read STORED entries that use a data descriptorMethod Detail |
---|
public ZipArchiveEntry getNextZipEntry() throws IOException
IOException
public ArchiveEntry getNextEntry() throws IOException
getNextEntry
in class ArchiveInputStream
null
if there are no more entries
IOException
- if the next entry could not be readpublic boolean canReadEntryData(ArchiveEntry ae)
May return false if it is set up to use encryption or a compression method that hasn't been implemented yet.
canReadEntryData
in class ArchiveInputStream
public int read(byte[] buffer, int start, int length) throws IOException
read
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public long skip(long value) throws IOException
This implementation may end up skipping over some smaller number of bytes, possibly 0, if and only if it reaches the end of the underlying stream.
The actual number of bytes skipped is returned.
skip
in class InputStream
value
- the number of bytes to be skipped.
IOException
- - if an I/O error occurs.
IllegalArgumentException
- - if value is negative.public static boolean matches(byte[] signature, int length)
signature
- the bytes to checklength
- the number of bytes to check
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |