/** * Transfer selected entries from this zipfile to a given #ZipArchiveOutputStream. * Compression and all other attributes will be as in this file. * <p>This method transfers entries based on the central directory of the zip file.</p> * * @param target The zipArchiveOutputStream to write the entries to * @param predicate A predicate that selects which entries to write * @throws IOException on error */ public void copyRawEntries(final ZipArchiveOutputStream target, final ZipArchiveEntryPredicate predicate) throws IOException { final Enumeration<ZipArchiveEntry> src = getEntriesInPhysicalOrder(); while (src.hasMoreElements()) { final ZipArchiveEntry entry = src.nextElement(); if (predicate.test( entry)) { target.addRawArchiveEntry(entry, getRawInputStream(entry)); } } }
/** * Write the contents of this scatter stream to a target archive. * * @param target The archive to receive the contents of this {@link ScatterZipOutputStream}. * @throws IOException If writing fails */ public void writeTo(final ZipArchiveOutputStream target) throws IOException { backingStore.closeForWriting(); try (final InputStream data = backingStore.getInputStream()) { for (final CompressedEntry compressedEntry : items) { try (final BoundedInputStream rawStream = new BoundedInputStream(data, compressedEntry.compressedSize)) { target.addRawArchiveEntry(compressedEntry.transferToArchiveEntry(), rawStream); } } } }
/** * Transfer selected entries from this zipfile to a given #ZipArchiveOutputStream. * Compression and all other attributes will be as in this file. * <p>This method transfers entries based on the central directory of the zip file.</p> * * @param target The zipArchiveOutputStream to write the entries to * @param predicate A predicate that selects which entries to write * @throws IOException on error */ public void copyRawEntries(final ZipArchiveOutputStream target, final ZipArchiveEntryPredicate predicate) throws IOException { final Enumeration<ZipArchiveEntry> src = getEntriesInPhysicalOrder(); while (src.hasMoreElements()) { final ZipArchiveEntry entry = src.nextElement(); if (predicate.test( entry)) { target.addRawArchiveEntry(entry, getRawInputStream(entry)); } } }
/** * Write the contents of this scatter stream to a target archive. * * @param target The archive to receive the contents of this {@link ScatterZipOutputStream}. * @throws IOException If writing fails */ public void writeTo(final ZipArchiveOutputStream target) throws IOException { backingStore.closeForWriting(); try (final InputStream data = backingStore.getInputStream()) { for (final CompressedEntry compressedEntry : items) { try (final BoundedInputStream rawStream = new BoundedInputStream(data, compressedEntry.compressedSize)) { target.addRawArchiveEntry(compressedEntry.transferToArchiveEntry(), rawStream); } } } }
zout.addRawArchiveEntry(strippedEntry, zip.getRawInputStream(entry));