in src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java [1225:1289]
public InputStream getInputStream(final ZipArchiveEntry entry) throws IOException {
if (!(entry instanceof Entry)) {
return null;
}
// cast validity is checked just above
ZipUtil.checkRequestedFeatures(entry);
// doesn't get closed if the method is not supported - which
// should never happen because of the checkRequestedFeatures
// call above
final InputStream is = new BufferedInputStream(getRawInputStream(entry)); // NOSONAR
switch (ZipMethod.getMethodByCode(entry.getMethod())) {
case STORED:
return new StoredStatisticsStream(is);
case UNSHRINKING:
return new UnshrinkingInputStream(is);
case IMPLODING:
try {
return new ExplodingInputStream(entry.getGeneralPurposeBit().getSlidingDictionarySize(),
entry.getGeneralPurposeBit().getNumberOfShannonFanoTrees(), is);
} catch (final IllegalArgumentException ex) {
throw new IOException("bad IMPLODE data", ex);
}
case DEFLATED:
final Inflater inflater = new Inflater(true);
// Inflater with nowrap=true has this odd contract for a zero padding
// byte following the data stream; this used to be zlib's requirement
// and has been fixed a long time ago, but the contract persists so
// we comply.
// https://docs.oracle.com/javase/8/docs/api/java/util/zip/Inflater.html#Inflater(boolean)
return new InflaterInputStreamWithStatistics(new SequenceInputStream(is, new ByteArrayInputStream(ONE_ZERO_BYTE)), inflater) {
@Override
public void close() throws IOException {
try {
super.close();
} finally {
inflater.end();
}
}
};
case BZIP2:
return new BZip2CompressorInputStream(is);
case ENHANCED_DEFLATED:
return new Deflate64CompressorInputStream(is);
case ZSTD:
case ZSTD_DEPRECATED:
return createZstdInputStream(is);
case XZ:
return new XZCompressorInputStream(is);
case AES_ENCRYPTED:
case EXPANDING_LEVEL_1:
case EXPANDING_LEVEL_2:
case EXPANDING_LEVEL_3:
case EXPANDING_LEVEL_4:
case JPEG:
case LZMA:
case PKWARE_IMPLODING:
case PPMD:
case TOKENIZATION:
case UNKNOWN:
case WAVPACK:
default:
throw new UnsupportedZipFeatureException(ZipMethod.getMethodByCode(entry.getMethod()), entry);
}
}