/** * Adds an archive entry with a raw input stream. * * If crc, size and compressed size are supplied on the entry, these values will be used as-is. * Zip64 status is re-established based on the settings in this stream, and the supplied value * is ignored. * * The entry is put and closed immediately. * * @param entry The archive entry to add * @param rawStream The raw input stream of a different entry. May be compressed/encrypted. * @throws IOException If copying fails */ public void addRawArchiveEntry(final ZipArchiveEntry entry, final InputStream rawStream) throws IOException { final ZipArchiveEntry ae = new ZipArchiveEntry(entry); if (hasZip64Extra(ae)) { // Will be re-added as required. this may make the file generated with this method // somewhat smaller than standard mode, // since standard mode is unable to remove the zip 64 header. ae.removeExtraField(Zip64ExtendedInformationExtraField.HEADER_ID); } final boolean is2PhaseSource = ae.getCrc() != ZipArchiveEntry.CRC_UNKNOWN && ae.getSize() != ArchiveEntry.SIZE_UNKNOWN && ae.getCompressedSize() != ArchiveEntry.SIZE_UNKNOWN; putArchiveEntry(ae, is2PhaseSource); copyFromZipInputStream(rawStream); closeCopiedEntry(is2PhaseSource); }
/** * Adds an archive entry with a raw input stream. * * If crc, size and compressed size are supplied on the entry, these values will be used as-is. * Zip64 status is re-established based on the settings in this stream, and the supplied value * is ignored. * * The entry is put and closed immediately. * * @param entry The archive entry to add * @param rawStream The raw input stream of a different entry. May be compressed/encrypted. * @throws IOException If copying fails */ public void addRawArchiveEntry(final ZipArchiveEntry entry, final InputStream rawStream) throws IOException { final ZipArchiveEntry ae = new ZipArchiveEntry(entry); if (hasZip64Extra(ae)) { // Will be re-added as required. this may make the file generated with this method // somewhat smaller than standard mode, // since standard mode is unable to remove the zip 64 header. ae.removeExtraField(Zip64ExtendedInformationExtraField.HEADER_ID); } final boolean is2PhaseSource = ae.getCrc() != ZipArchiveEntry.CRC_UNKNOWN && ae.getSize() != ArchiveEntry.SIZE_UNKNOWN && ae.getCompressedSize() != ArchiveEntry.SIZE_UNKNOWN; putArchiveEntry(ae, is2PhaseSource); copyFromZipInputStream(rawStream); closeCopiedEntry(is2PhaseSource); }