/** * Deflate the given source using the supplied compression method * * @param source The source to compress * @param method The #ZipArchiveEntry compression method * @throws IOException When failures happen */ public void deflate(final InputStream source, final int method) throws IOException { reset(); int length; while ((length = source.read(readerBuf, 0, readerBuf.length)) >= 0) { write(readerBuf, 0, length, method); } if (method == ZipEntry.DEFLATED) { flushDeflater(); } }
/** * Writes all necessary data for this entry. * @throws IOException on error * @throws Zip64RequiredException if the entry's uncompressed or * compressed size exceeds 4 GByte and {@link #setUseZip64} * is {@link Zip64Mode#Never}. */ @Override public void closeArchiveEntry() throws IOException { preClose(); flushDeflater(); final long bytesWritten = streamCompressor.getTotalBytesWritten() - entry.dataStart; final long realCrc = streamCompressor.getCrc32(); entry.bytesRead = streamCompressor.getBytesRead(); final Zip64Mode effectiveMode = getEffectiveZip64Mode(entry.entry); final boolean actuallyNeedsZip64 = handleSizesAndCrc(bytesWritten, realCrc, effectiveMode); closeEntry(actuallyNeedsZip64, false); streamCompressor.reset(); }
/** * Deflate the given source using the supplied compression method * * @param source The source to compress * @param method The #ZipArchiveEntry compression method * @throws IOException When failures happen */ public void deflate(final InputStream source, final int method) throws IOException { reset(); int length; while ((length = source.read(readerBuf, 0, readerBuf.length)) >= 0) { write(readerBuf, 0, length, method); } if (method == ZipEntry.DEFLATED) { flushDeflater(); } }
/** * Writes all necessary data for this entry. * @throws IOException on error * @throws Zip64RequiredException if the entry's uncompressed or * compressed size exceeds 4 GByte and {@link #setUseZip64} * is {@link Zip64Mode#Never}. */ @Override public void closeArchiveEntry() throws IOException { preClose(); flushDeflater(); final long bytesWritten = streamCompressor.getTotalBytesWritten() - entry.dataStart; final long realCrc = streamCompressor.getCrc32(); entry.bytesRead = streamCompressor.getBytesRead(); final Zip64Mode effectiveMode = getEffectiveZip64Mode(entry.entry); final boolean actuallyNeedsZip64 = handleSizesAndCrc(bytesWritten, realCrc, effectiveMode); closeEntry(actuallyNeedsZip64, false); streamCompressor.reset(); }