Top Description Inners Fields Constructors Methods
org.apache.commons.compress.archivers.zip

public Class ZipArchiveInputStream

extends ArchiveInputStream<ZipArchiveEntry>
implements InputStreamStatistics
Class Inheritance
All Implemented Interfaces
org.apache.commons.compress.utils.InputStreamStatistics
Known Direct Subclasses
org.apache.commons.compress.archivers.jar.JarArchiveInputStream
Static Imports
org.apache.commons.compress.archivers.zip.ZipConstants.DWORD, .ZipConstants.SHORT, .ZipConstants.WORD, .ZipConstants.ZIP64_MAGIC

Implements an input stream that can read Zip archives.

As of Apache Commons Compress it transparently supports Zip64 extensions and thus individual entries and archives larger than 4 GB or with more than 65,536 entries.

The ZipFile class is preferred when reading from files as ZipArchiveInputStream is limited by not being able to read the central directory header before returning entries. In particular ZipArchiveInputStream

See Also
ZipFile

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ZipArchiveInputStream.BoundCountInputStream

Input stream adapted from commons-io.

private static class
ZipArchiveInputStream.CurrentEntry

Structure collecting information for the entry that is currently being read.

Field Summary

Modifier and TypeField and Description
private final boolean
allowStoredEntriesWithDataDescriptor

Whether the stream will try to read STORED entries that use a data descriptor.

private static final byte[]
private final ByteBuffer
buf

Buffer used to read from the wrapped stream.

private static final byte[]
private static final int
private boolean
closed

Whether the stream has been closed.

private ZipArchiveInputStream.CurrentEntry
current

The entry that is currently being read.

private static final byte[]
private int
private Function<ZipShort, ZipExtraField>
extraFieldSupport

The factory for extra fields or null.

private boolean
hitCentralDirectory

Whether the stream has reached the central directory - and thus found all entries.

private final Inflater
inf

Inflater used for all deflated entries.

private ByteArrayInputStream
lastStoredEntry

When reading a stored entry that uses the data descriptor this stream has to read the full entry and caches it.

private static final byte[]
private static final int
private final byte[]
lfhBuf

Cached buffers - must only be used locally in the class (COMPRESS-172 - reduce garbage collection).

private static final BigInteger
public static final int
private final byte[]
private final byte[]
private final boolean
skipSplitSig

Whether the stream will try to skip the ZIP split signature(08074B50) at the beginning

private static final long
private final byte[]
private long
uncompressedCount

Count decompressed bytes for current entry

private static final String
private final boolean
useUnicodeExtraFields

Whether to look for and use Unicode extra fields.

private final byte[]
private final ZipEncoding
zipEncoding

The ZIP encoding to use for file names and the file comment.

Constructor Summary

AccessConstructor and Description
public
ZipArchiveInputStream(final InputStream
the stream to wrap
inputStream
)

Constructs an instance using UTF-8 encoding

public
ZipArchiveInputStream(final InputStream
the stream to wrap
inputStream
,
final String
the encoding to use for file names, use null for the platform's default encoding
encoding
)

Constructs an instance using the specified encoding

public
ZipArchiveInputStream(final InputStream
the stream to wrap
inputStream
,
final String
the encoding to use for file names, use null for the platform's default encoding
encoding
,
final boolean
whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.
useUnicodeExtraFields
)

Constructs an instance using the specified encoding

public
ZipArchiveInputStream(final InputStream
the stream to wrap
inputStream
,
final String
the encoding to use for file names, use null for the platform's default encoding
encoding
,
final boolean
whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.
useUnicodeExtraFields
,
final boolean
whether the stream will try to read STORED entries that use a data descriptor
allowStoredEntriesWithDataDescriptor
)

Constructs an instance using the specified encoding

public
ZipArchiveInputStream(final InputStream
the stream to wrap
inputStream
,
final String
the encoding to use for file names, use null for the platform's default encoding
encoding
,
final boolean
whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.
useUnicodeExtraFields
,
final boolean
whether the stream will try to read STORED entries that use a data descriptor
allowStoredEntriesWithDataDescriptor
,
final boolean
Whether the stream will try to skip the zip split signature(08074B50) at the beginning. You will need to set this to true if you want to read a split archive.
skipSplitSig
)

Constructs an instance using the specified encoding

Method Summary

Modifier and TypeMethod and Description
private boolean
bufferContainsSignature(final ByteArrayOutputStream bos, final int offset, final int lastRead, final int expectedDDLen)

Checks whether the current buffer contains the signature of a "data descriptor", "local file header" or "central directory entry".

private int
cacheBytesRead(final ByteArrayOutputStream bos, int offset, final int lastRead, final int expectedDDLen)

If the last read bytes could hold a data descriptor and an incomplete signature then save the last bytes to the front of the buffer and cache everything in front of the potential data descriptor into the given ByteArrayOutputStream.

public boolean
canReadEntryData(final ArchiveEntry
the entry to test
ae
)

Overrides org.apache.commons.compress.archivers.ArchiveInputStream.canReadEntryData.

Whether this class is able to read the given entry.
private static boolean
checksig(final byte[] expected, final byte[] signature)

public void
close()

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.
private void
closeEntry()

Closes the current ZIP archive entry and positions the underlying stream to the beginning of the next entry.

private boolean

Returns:

true, if current entry is determined to have outstanding bytes, false otherwise
currentEntryHasOutstandingBytes
()

If the compressed size of the current entry is included in the entry header and there are any outstanding bytes in the underlying stream, then this returns true.

private void
drainCurrentEntryData()

Read all data of the current entry from the underlying stream that hasn't been read, yet.

private int
fill()

private boolean
findEocdRecord()

Reads forward until the signature of the "End of central directory" record is found.

private long
getBytesInflated()

Gets the number of bytes Inflater has actually processed.

public long
getCompressedCount()

Implements org.apache.commons.compress.utils.InputStreamStatistics.getCompressedCount.

Gets the amount of raw or compressed bytes read by the stream.
public ZipArchiveEntry
getNextEntry()

Implements abstract org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Gets the next Archive Entry in this Stream.
public ZipArchiveEntry

Returns:

the next entry.
getNextZipEntry
()

Deprecated Use getNextEntry().
Gets the next entry.
public long
private boolean

Returns:

true if this looks like an APK signing block
isApkSigningBlock
(final byte[]
the bytes read from the underlying stream in the expectation that they would hold the local file header of the next entry.
suspectLocalFileHeader
)

Checks whether this might be an APK Signing Block.

private boolean
isFirstByteOfEocdSig(final int b)

public static boolean

Returns:

true, if this stream is a ZIP archive stream, false otherwise
matches
(final byte[]
the bytes to check
signature
,
final int
the number of bytes to check
length
)

Checks if the signature matches what is expected for a ZIP file.

private void
processZip64Extra(final ZipLong size, final ZipLong cSize)

Records whether a Zip64 extra is present and sets the size information from it if sizes are 0xFFFFFFFF and the entry doesn't use a data descriptor.

private void
pushback(final byte[] buf, final int offset, final int length)

public int
read(final byte[]
the buffer into which the data is read.
buffer
,
final int
the start offset in array b at which the data is written.
offset
,
final int
the maximum number of bytes to read.
length
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.
private void
private int
readDeflated(final byte[] buffer, final int offset, final int length)

Implementation of read for DEFLATED entries.

private boolean
readFirstLocalFileHeader()

Fills the given array with the first local file header and deals with splitting/spanning markers that may prefix the first LFH.

private int
readFromInflater(final byte[] buffer, final int offset, final int length)

Potentially reads more bytes to fill the inflater's buffer and reads from it.

private void
readFully(final byte[] b)

private void
readFully(final byte[] b, final int off)

private int
readOneByte()

Reads bytes by reading from the underlying stream rather than the (potentially inflating) archive stream - which read would do.

private byte[]
readRange(final int len)

private int
readStored(final byte[] buffer, final int offset, final int length)

Implementation of read for STORED entries.

private void
readStoredEntry()

Caches a stored entry that uses the data descriptor.

private void
realSkip(final long value)

Skips bytes by reading from the underlying stream rather than the (potentially inflating) archive stream - which skip would do.

public ZipArchiveInputStream

Returns:

the archive.
setExtraFieldSupport
(final Function<ZipShort, ZipExtraField>
the lookup function based on extra field header id.
extraFieldSupport
)

Enable custom extra fields factory.

public long

Returns:

the actual number of bytes skipped.
skip
(final long
the number of bytes to be skipped.
value
)

Overrides java.io.FilterInputStream.skip.

Skips over and discards value bytes of data from this input stream.
private void
skipRemainderOfArchive(final boolean read)

Reads the stream until it find the "End of central directory record" and consumes it as well.

private boolean
supportsCompressedSizeFor(final ZipArchiveEntry entry)

Whether the compressed size for the entry is either known or not required by the compression method being used.

private boolean

Returns:

true if allowStoredEntriesWithDataDescriptor is true, the entry doesn't require any data descriptor or the method is DEFLATED or ENHANCED_DEFLATED.
supportsDataDescriptorFor
(final ZipArchiveEntry entry)

Whether this entry requires a data descriptor this library can work with.

Inherited from org.apache.commons.compress.archivers.ArchiveInputStream:
countcountgetBytesReadgetCharsetgetCountpushedBackBytesread

Field Detail

allowStoredEntriesWithDataDescriptorback to summary
private final boolean allowStoredEntriesWithDataDescriptor

Whether the stream will try to read STORED entries that use a data descriptor. Setting it to true means we will not stop reading an entry with the compressed size, instead we will stop reading an entry when a data descriptor is met (by finding the Data Descriptor Signature). This will completely break down in some cases - like JARs in WARs.

See also : https://issues.apache.org/jira/projects/COMPRESS/issues/COMPRESS-555 https://github.com/apache/commons-compress/pull/137#issuecomment-690835644

APK_SIGNING_BLOCK_MAGICback to summary
private static final byte[] APK_SIGNING_BLOCK_MAGIC
bufback to summary
private final ByteBuffer buf

Buffer used to read from the wrapped stream.

CFHback to summary
private static final byte[] CFH
CFH_LENback to summary
private static final int CFH_LEN
closedback to summary
private boolean closed

Whether the stream has been closed.

currentback to summary
private ZipArchiveInputStream.CurrentEntry current

The entry that is currently being read.

DDback to summary
private static final byte[] DD
entriesReadback to summary
private int entriesRead
extraFieldSupportback to summary
private Function<ZipShort, ZipExtraField> extraFieldSupport

The factory for extra fields or null.

hitCentralDirectoryback to summary
private boolean hitCentralDirectory

Whether the stream has reached the central directory - and thus found all entries.

infback to summary
private final Inflater inf

Inflater used for all deflated entries.

lastStoredEntryback to summary
private ByteArrayInputStream lastStoredEntry

When reading a stored entry that uses the data descriptor this stream has to read the full entry and caches it. This is the cache.

LFHback to summary
private static final byte[] LFH
LFH_LENback to summary
private static final int LFH_LEN
lfhBufback to summary
private final byte[] lfhBuf

Cached buffers - must only be used locally in the class (COMPRESS-172 - reduce garbage collection).

LONG_MAXback to summary
private static final BigInteger LONG_MAX
PREAMBLE_GARBAGE_MAX_SIZEback to summary
public static final int PREAMBLE_GARBAGE_MAX_SIZE
shortBufback to summary
private final byte[] shortBuf
skipBufback to summary
private final byte[] skipBuf
skipSplitSigback to summary
private final boolean skipSplitSig

Whether the stream will try to skip the ZIP split signature(08074B50) at the beginning

TWO_EXP_32back to summary
private static final long TWO_EXP_32
twoDwordBufback to summary
private final byte[] twoDwordBuf
uncompressedCountback to summary
private long uncompressedCount

Count decompressed bytes for current entry

USE_ZIPFILE_INSTEAD_OF_STREAM_DISCLAIMERback to summary
private static final String USE_ZIPFILE_INSTEAD_OF_STREAM_DISCLAIMER
useUnicodeExtraFieldsback to summary
private final boolean useUnicodeExtraFields

Whether to look for and use Unicode extra fields.

wordBufback to summary
private final byte[] wordBuf
zipEncodingback to summary
private final ZipEncoding zipEncoding

The ZIP encoding to use for file names and the file comment.

Constructor Detail

ZipArchiveInputStreamback to summary
public ZipArchiveInputStream(final InputStream inputStream)

Constructs an instance using UTF-8 encoding

Parameters
inputStream:InputStream

the stream to wrap

ZipArchiveInputStreamback to summary
public ZipArchiveInputStream(final InputStream inputStream, final String encoding)

Constructs an instance using the specified encoding

Parameters
inputStream:InputStream

the stream to wrap

encoding:String

the encoding to use for file names, use null for the platform's default encoding

Since
1.5
ZipArchiveInputStreamback to summary
public ZipArchiveInputStream(final InputStream inputStream, final String encoding, final boolean useUnicodeExtraFields)

Constructs an instance using the specified encoding

Parameters
inputStream:InputStream

the stream to wrap

encoding:String

the encoding to use for file names, use null for the platform's default encoding

useUnicodeExtraFields:boolean

whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.

ZipArchiveInputStreamback to summary
public ZipArchiveInputStream(final InputStream inputStream, final String encoding, final boolean useUnicodeExtraFields, final boolean allowStoredEntriesWithDataDescriptor)

Constructs an instance using the specified encoding

Parameters
inputStream:InputStream

the stream to wrap

encoding:String

the encoding to use for file names, use null for the platform's default encoding

useUnicodeExtraFields:boolean

whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.

allowStoredEntriesWithDataDescriptor:boolean

whether the stream will try to read STORED entries that use a data descriptor

Since
1.1
ZipArchiveInputStreamback to summary
public ZipArchiveInputStream(final InputStream inputStream, final String encoding, final boolean useUnicodeExtraFields, final boolean allowStoredEntriesWithDataDescriptor, final boolean skipSplitSig)

Constructs an instance using the specified encoding

Parameters
inputStream:InputStream

the stream to wrap

encoding:String

the encoding to use for file names, use null for the platform's default encoding

useUnicodeExtraFields:boolean

whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.

allowStoredEntriesWithDataDescriptor:boolean

whether the stream will try to read STORED entries that use a data descriptor

skipSplitSig:boolean

Whether the stream will try to skip the zip split signature(08074B50) at the beginning. You will need to set this to true if you want to read a split archive.

Since
1.20

Method Detail

bufferContainsSignatureback to summary
private boolean bufferContainsSignature(final ByteArrayOutputStream bos, final int offset, final int lastRead, final int expectedDDLen) throws IOException

Checks whether the current buffer contains the signature of a "data descriptor", "local file header" or "central directory entry".

If it contains such a signature, reads the data descriptor and positions the stream right after the data descriptor.

cacheBytesReadback to summary
private int cacheBytesRead(final ByteArrayOutputStream bos, int offset, final int lastRead, final int expectedDDLen)

If the last read bytes could hold a data descriptor and an incomplete signature then save the last bytes to the front of the buffer and cache everything in front of the potential data descriptor into the given ByteArrayOutputStream.

Data descriptor plus incomplete signature (3 bytes in the worst case) can be 20 bytes max.

canReadEntryDataback to summary
public boolean canReadEntryData(final ArchiveEntry ae)

Overrides org.apache.commons.compress.archivers.ArchiveInputStream.canReadEntryData.

Whether this class is able to read the given entry.

May return false if it is set up to use encryption or a compression method that hasn't been implemented yet.

Parameters
ae:ArchiveEntry

Doc from org.apache.commons.compress.archivers.ArchiveInputStream.canReadEntryData.

the entry to test

Returns:boolean

Doc from org.apache.commons.compress.archivers.ArchiveInputStream.canReadEntryData.

This implementation always returns true.

Annotations
@Override
Since
1.1
checksigback to summary
private static boolean checksig(final byte[] expected, final byte[] signature)
closeback to summary
public void close() throws IOException

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterInputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
closeEntryback to summary
private void closeEntry() throws IOException

Closes the current ZIP archive entry and positions the underlying stream to the beginning of the next entry. All per-entry variables and data structures are cleared.

If the compressed size of this entry is included in the entry header, then any outstanding bytes are simply skipped from the underlying stream without uncompressing them. This allows an entry to be safely closed even if the compression method is unsupported.

In case we don't know the compressed size of this entry or have already buffered too much data from the underlying stream to support uncompression, then the uncompression process is completed and the end position of the stream is adjusted based on the result of that process.

Exceptions
IOException:
if an error occurs
currentEntryHasOutstandingBytesback to summary
private boolean currentEntryHasOutstandingBytes()

If the compressed size of the current entry is included in the entry header and there are any outstanding bytes in the underlying stream, then this returns true.

Returns:boolean

true, if current entry is determined to have outstanding bytes, false otherwise

drainCurrentEntryDataback to summary
private void drainCurrentEntryData() throws IOException

Read all data of the current entry from the underlying stream that hasn't been read, yet.

fillback to summary
private int fill() throws IOException
findEocdRecordback to summary
private boolean findEocdRecord() throws IOException

Reads forward until the signature of the "End of central directory" record is found.

getBytesInflatedback to summary
private long getBytesInflated()

Gets the number of bytes Inflater has actually processed.

for Java < Java7 the getBytes* methods in Inflater/Deflater seem to return unsigned ints rather than longs that start over with 0 at 2^32.

The stream knows how many bytes it has read, but not how many the Inflater actually consumed - it should be between the total number of bytes read for the entry and the total number minus the last read operation. Here we just try to make the value close enough to the bytes we've read by assuming the number of bytes consumed must be smaller than (or equal to) the number of bytes read but not smaller by more than 2^32.

getCompressedCountback to summary
public long getCompressedCount()

Implements org.apache.commons.compress.utils.InputStreamStatistics.getCompressedCount.

Doc from org.apache.commons.compress.utils.InputStreamStatistics.getCompressedCount.

Gets the amount of raw or compressed bytes read by the stream.

Returns:long

the amount of raw or compressed bytes read by the stream.

Annotations
@SuppressWarnings:resource
@Override
Since
1.17
getNextEntryback to summary
public ZipArchiveEntry getNextEntry() throws IOException

Implements abstract org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Doc from org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Gets the next Archive Entry in this Stream.

Returns:ZipArchiveEntry

the next entry, or null if there are no more entries

Annotations
@Override
Exceptions
IOException:
if the next entry could not be read
getNextZipEntryback to summary
public ZipArchiveEntry getNextZipEntry() throws IOException

Deprecated

Use getNextEntry().

Gets the next entry.

Returns:ZipArchiveEntry

the next entry.

Annotations
@Deprecated
Exceptions
IOException:
if an I/O error occurs.
getUncompressedCountback to summary
public long getUncompressedCount()

Implements org.apache.commons.compress.utils.InputStreamStatistics.getUncompressedCount.

Gets the uncompressed count.

Returns:long

Doc from org.apache.commons.compress.utils.InputStreamStatistics.getUncompressedCount.

the amount of decompressed bytes returned by the stream.

Annotations
@Override
Since
1.17
isApkSigningBlockback to summary
private boolean isApkSigningBlock(final byte[] suspectLocalFileHeader) throws IOException

Checks whether this might be an APK Signing Block.

Unfortunately the APK signing block does not start with some kind of signature, it rather ends with one. It starts with a length, so what we do is parse the suspect length, skip ahead far enough, look for the signature and if we've found it, return true.

Parameters
suspectLocalFileHeader:byte[]

the bytes read from the underlying stream in the expectation that they would hold the local file header of the next entry.

Returns:boolean

true if this looks like an APK signing block

See Also
https://source.android.com/security/apksigning/v2
isFirstByteOfEocdSigback to summary
private boolean isFirstByteOfEocdSig(final int b)
matchesback to summary
public static boolean matches(final byte[] signature, final int length)

Checks if the signature matches what is expected for a ZIP file. Does not currently handle self-extracting ZIPs which may have arbitrary leading content.

Parameters
signature:byte[]

the bytes to check

length:int

the number of bytes to check

Returns:boolean

true, if this stream is a ZIP archive stream, false otherwise

processZip64Extraback to summary
private void processZip64Extra(final ZipLong size, final ZipLong cSize) throws ZipException

Records whether a Zip64 extra is present and sets the size information from it if sizes are 0xFFFFFFFF and the entry doesn't use a data descriptor.

pushbackback to summary
private void pushback(final byte[] buf, final int offset, final int length) throws IOException
readback to summary
public int read(final byte[] buffer, final int offset, final int length) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
buffer:byte[]

the buffer into which the data is read.

offset:int

the start offset in array b at which the data is written.

length:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readDataDescriptorback to summary
private void readDataDescriptor() throws IOException
readDeflatedback to summary
private int readDeflated(final byte[] buffer, final int offset, final int length) throws IOException

Implementation of read for DEFLATED entries.

readFirstLocalFileHeaderback to summary
private boolean readFirstLocalFileHeader() throws IOException

Fills the given array with the first local file header and deals with splitting/spanning markers that may prefix the first LFH.

readFromInflaterback to summary
private int readFromInflater(final byte[] buffer, final int offset, final int length) throws IOException

Potentially reads more bytes to fill the inflater's buffer and reads from it.

readFullyback to summary
private void readFully(final byte[] b) throws IOException
readFullyback to summary
private void readFully(final byte[] b, final int off) throws IOException
readOneByteback to summary
private int readOneByte() throws IOException

Reads bytes by reading from the underlying stream rather than the (potentially inflating) archive stream - which read would do. Also updates bytes-read counter.

readRangeback to summary
private byte[] readRange(final int len) throws IOException
readStoredback to summary
private int readStored(final byte[] buffer, final int offset, final int length) throws IOException

Implementation of read for STORED entries.

readStoredEntryback to summary
private void readStoredEntry() throws IOException

Caches a stored entry that uses the data descriptor.

  • Reads a stored entry until the signature of a local file header, central directory header or data descriptor has been found.
  • Stores all entry data in lastStoredEntry.

  • Rewinds the stream to position at the data descriptor.
  • reads the data descriptor

After calling this method the entry should know its size, the entry's data is cached and the stream is positioned at the next local file or central directory header.

realSkipback to summary
private void realSkip(final long value) throws IOException

Skips bytes by reading from the underlying stream rather than the (potentially inflating) archive stream - which skip would do. Also updates bytes-read counter.

setExtraFieldSupportback to summary
public ZipArchiveInputStream setExtraFieldSupport(final Function<ZipShort, ZipExtraField> extraFieldSupport)

Enable custom extra fields factory.

Parameters
extraFieldSupport:Function<ZipShort, ZipExtraField>

the lookup function based on extra field header id.

Returns:ZipArchiveInputStream

the archive.

skipback to summary
public long skip(final long value) throws IOException

Overrides java.io.FilterInputStream.skip.

Skips over and discards value bytes of data from this input stream.

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.

Parameters
value:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped.

Annotations
@Override
Exceptions
IOException:
- if an I/O error occurs.
IllegalArgumentException:
- if value is negative.
skipRemainderOfArchiveback to summary
private void skipRemainderOfArchive(final boolean read) throws IOException

Reads the stream until it find the "End of central directory record" and consumes it as well.

supportsCompressedSizeForback to summary
private boolean supportsCompressedSizeFor(final ZipArchiveEntry entry)

Whether the compressed size for the entry is either known or not required by the compression method being used.

supportsDataDescriptorForback to summary
private boolean supportsDataDescriptorFor(final ZipArchiveEntry entry)

Whether this entry requires a data descriptor this library can work with.

Returns:boolean

true if allowStoredEntriesWithDataDescriptor is true, the entry doesn't require any data descriptor or the method is DEFLATED or ENHANCED_DEFLATED.

org.apache.commons.compress.archivers.zip back to summary

private final Class ZipArchiveInputStream.BoundCountInputStream

extends BoundedInputStream
Class Inheritance

Input stream adapted from commons-io.

Constructor Summary

AccessConstructor and Description
pack-priv
BoundCountInputStream(final InputStream
The wrapped input stream
in
,
final long
The maximum number of bytes to return
max
)

Creates a new BoundedInputStream that wraps the given input stream and limits it to a certain size.

Method Summary

Modifier and TypeMethod and Description
private boolean
public int
read()

Overrides org.apache.commons.io.input.BoundedInputStream.read.

Invokes the delegate's read() method if the current position is less than the limit.
public int
read(final byte[]
the buffer to read the bytes into
b
,
final int
The start offset
off
,
final int
The number of bytes to read
len
)

Overrides org.apache.commons.io.input.BoundedInputStream.read.

Invokes the delegate's read(byte[], int, int) method.
private int
readCount(final int bytesRead)

Inherited from org.apache.commons.io.input.BoundedInputStream:
availableclosegetCountgetMaxLengthisPropagateClosemarkmarkSupportedonMaxLengthreadresetsetPropagateCloseskiptoString

Constructor Detail

BoundCountInputStreamback to summary
pack-priv BoundCountInputStream(final InputStream in, final long max)

Creates a new BoundedInputStream that wraps the given input stream and limits it to a certain size.

Parameters
in:InputStream

The wrapped input stream

max:long

The maximum number of bytes to return

Method Detail

atMaxLengthback to summary
private boolean atMaxLength()
readback to summary
public int read() throws IOException

Overrides org.apache.commons.io.input.BoundedInputStream.read.

Doc from org.apache.commons.io.input.BoundedInputStream.read.

Invokes the delegate's read() method if the current position is less than the limit.

Returns:int

the byte read or -1 if the end of stream or the limit has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Overrides org.apache.commons.io.input.BoundedInputStream.read.

Doc from org.apache.commons.io.input.BoundedInputStream.read.

Invokes the delegate's read(byte[], int, int) method.

Parameters
b:byte[]

the buffer to read the bytes into

off:int

The start offset

len:int

The number of bytes to read

Returns:int

the number of bytes read or -1 if the end of stream or the limit has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readCountback to summary
private int readCount(final int bytesRead)
org.apache.commons.compress.archivers.zip back to summary

private final Class ZipArchiveInputStream.CurrentEntry

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.CurrentEntry

Structure collecting information for the entry that is currently being read.

Field Summary

Modifier and TypeField and Description
private long
bytesRead

Number of bytes of entry content read by the client if the entry is STORED.

private long
bytesReadFromStream

Number of bytes of entry content read from the stream.

private final CRC32
crc

The checksum calculated as the current entry is read.

private final ZipArchiveEntry
entry

Current ZIP entry.

private boolean
hasDataDescriptor

Does the entry use a data descriptor?

private InputStream
inputStream

The input stream decompressing the data for shrunk and imploded entries.

private boolean
usesZip64

Does the entry have a ZIP64 extended information extra field.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private <T extends InputStream> T
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bytesReadback to summary
private long bytesRead

Number of bytes of entry content read by the client if the entry is STORED.

bytesReadFromStreamback to summary
private long bytesReadFromStream

Number of bytes of entry content read from the stream.

This may be more than the actual entry's length as some stuff gets buffered up and needs to be pushed back when the end of the entry has been reached.

crcback to summary
private final CRC32 crc

The checksum calculated as the current entry is read.

entryback to summary
private final ZipArchiveEntry entry

Current ZIP entry.

hasDataDescriptorback to summary
private boolean hasDataDescriptor

Does the entry use a data descriptor?

inputStreamback to summary
private InputStream inputStream

The input stream decompressing the data for shrunk and imploded entries.

usesZip64back to summary
private boolean usesZip64

Does the entry have a ZIP64 extended information extra field.

Constructor Detail

CurrentEntryback to summary
private CurrentEntry()

Method Detail

checkInputStreamback to summary
private <T extends InputStream> T checkInputStream()
Annotations
@SuppressWarnings:unchecked