out.setLevel(ZipArchiveOutputStream.DEFAULT_COMPRESSION); try
@Override public void open() throws IOException { outputZip = new ZipArchiveOutputStream(filePath.toFile()); outputZip.setEncoding("UTF-8"); outputZip.setLevel(9); ZipArchiveEntry zipEntry = new ZipArchiveEntry("corpus.xml"); outputZip.putArchiveEntry(zipEntry); }
final ZipArchiveOutputStream zipArchive = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(target))); zipArchive.setLevel(Deflater.BEST_COMPRESSION); archive = zipArchive; } else {
try { final ZipArchiveOutputStream zipStream = new ZipArchiveOutputStream(new BufferedOutputStream(out)); zipStream.setLevel(Deflater.BEST_SPEED); SimpleFileVisitor<java.nio.file.Path> zipper = new SimpleFileVisitor<java.nio.file.Path>() { @Override
final File targetFile = distributionFile(rootDirectory, artifactBase + ".zip"); try (ZipArchiveOutputStream zip = new ZipArchiveOutputStream(targetFile)) { zip.setLevel(9); appendRecursively(sourceDirectory, artifactBase, zip);
public static MediaResource getZippedDerivateMediaResource(String object) { final Path tempFile; try { tempFile = Files.createTempFile("swordv2_", ".temp.zip"); } catch (IOException e) { throw new MCRException("Could not create temp file!", e); } try (final OutputStream tempFileStream = Files.newOutputStream(tempFile)) { final ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(tempFileStream); zipOutputStream.setLevel(Deflater.BEST_COMPRESSION); final MCRPath root = MCRPath.getPath(object, "/"); addDirectoryToZip(zipOutputStream, root); zipOutputStream.close(); } catch (IOException e) { throw new MCRException(e); } MediaResource resultRessource; InputStream is; try { is = new MCRDeleteFileOnCloseFilterInputStream(Files.newInputStream(tempFile), tempFile); resultRessource = new MediaResource(is, MCRSwordConstants.MIME_TYPE_APPLICATION_ZIP, UriRegistry.PACKAGE_SIMPLE_ZIP); } catch (IOException e) { throw new MCRException("could not read from temp file!", e); } return resultRessource; }
private void configure(ZipArchiveOutputStream o) { o.setLevel(level); o.setComment(comment); o.setFallbackToUTF8(fallBackToUTF8); o.setUseLanguageEncodingFlag(useLanguageEncodingFlag); o.setCreateUnicodeExtraFields(createUnicodeExtraFields.getPolicy()); o.setUseZip64(zip64Mode.getPolicy()); }
@Override public void decrypt(XKey key, InputStream in, OutputStream out) throws IOException { ZipArchiveInputStream zis = null; ZipArchiveOutputStream zos = null; try { zis = new ZipArchiveInputStream(in); zos = new ZipArchiveOutputStream(out); zos.setLevel(level); XUnclosedOutputStream nos = new XUnclosedOutputStream(zos); ZipArchiveEntry entry; while ((entry = zis.getNextZipEntry()) != null) { if (entry.isDirectory()) { continue; } zos.putArchiveEntry(new ZipArchiveEntry(entry.getName())); XDecryptor decryptor = filtrate(entry) ? this : xNopDecryptor; try (OutputStream eos = decryptor.decrypt(key, nos)) { XKit.transfer(zis, eos); } zos.closeArchiveEntry(); } zos.finish(); } finally { XKit.close(zis); XKit.close(zos); } }
@Override public void encrypt(XKey key, InputStream in, OutputStream out) throws IOException { ZipArchiveInputStream zis = null; ZipArchiveOutputStream zos = null; try { zis = new ZipArchiveInputStream(in); zos = new ZipArchiveOutputStream(out); zos.setLevel(level); XUnclosedOutputStream nos = new XUnclosedOutputStream(zos); ZipArchiveEntry entry; while ((entry = zis.getNextZipEntry()) != null) { if (entry.isDirectory()) { continue; } zos.putArchiveEntry(new ZipArchiveEntry(entry.getName())); XEncryptor encryptor = filtrate(entry) ? this : xNopEncryptor; try (OutputStream eos = encryptor.encrypt(key, nos)) { XKit.transfer(zis, eos); } zos.closeArchiveEntry(); } zos.finish(); } finally { XKit.close(zis); XKit.close(zos); } } }