/** * 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 bytes to ZIP entry. * @param b the byte array to write * @param offset the start position to write from * @param length the number of bytes to write * @throws IOException on error */ @Override public void write(final byte[] b, final int offset, final int length) throws IOException { if (entry == null) { throw new IllegalStateException("No current entry"); } ZipUtil.checkRequestedFeatures(entry.entry); final long writtenThisTime = streamCompressor.write(b, offset, length, entry.entry.getMethod()); count(writtenThisTime); }
/** * 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 bytes to ZIP entry. * @param b the byte array to write * @param offset the start position to write from * @param length the number of bytes to write * @throws IOException on error */ @Override public void write(final byte[] b, final int offset, final int length) throws IOException { if (entry == null) { throw new IllegalStateException("No current entry"); } ZipUtil.checkRequestedFeatures(entry.entry); final long writtenThisTime = streamCompressor.write(b, offset, length, entry.entry.getMethod()); count(writtenThisTime); }