out.setMethod(ZipOutputStream.STORED); CRC32 crc = new CRC32(); crc.update(data);
try { ZipOutputStream z = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(f))); z.setMethod(ZipOutputStream.DEFLATED);
out.setMethod( ZipOutputStream.DEFLATED ); out.setLevel( Deflater.BEST_COMPRESSION );
out.setMethod( ZipOutputStream.DEFLATED );
public ZipWriter setMethod(int method) { out.setMethod(method); return this; }
Writer(OutputStream output) throws IOException { if (output == null) { throw new IllegalArgumentException("output must not be null"); //$NON-NLS-1$ } this.output = new ZipOutputStream(output); this.output.setMethod(ZipOutputStream.DEFLATED); this.output.setLevel(0); this.output.putNextEntry(new ZipEntry(FIRST_ENTRY_NAME)); this.output.closeEntry(); }
public static void compress(File source, File zipFile) throws IOException { ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile))); out.setMethod(ZipOutputStream.DEFLATED); try { addFileOrDirectory(source, source, out); out.close(); } catch (IOException e) { throw new RuntimeException("Zipping the report failed"); } }
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(target)); zos.setMethod( ZipOutputStream.DEFLATED ); zos.setLevel( 5 ); ...
// Zip ZipOutputStream zipOut = ... zipOut.setMethod(ZipOutputStream.STORED); // No compression. for(int i = 0; i < tableModel.getRowCount(); i++) { // Single file File originalFile = (File) tableModel.getValueAt(i, 0); FileInputStream originalStream = new FileInputStream(originalFile); // GZipped single file: GZipOutputStream gzipOut = ...; ... // Input of the gzipped thing InputStream gzipResultIn = ... // Make a new ZipEntry: ZipEntry zipEntry = new ZipEntry(originalFile.getName() + ".gz.enc"); zipOut.putNextEntry(zipEntry); encrypt(key, gzipResultIn, zipOut); // Should not close the input zipOut.closeEntry(); } zipOut.close();
public ZipBuilder(File archiveFile, boolean useCompression, boolean verbose) throws IOException { zout = getArchiveOutputStream(archiveFile); if (useCompression) { zout.setMethod(ZipEntry.DEFLATED); zout.setLevel(9); } else { zout.setMethod(ZipEntry.STORED); zout.setLevel(0); } this.verbose = verbose; }
public ZipBuilder(File archiveFile, boolean useCompression, boolean verbose) throws IOException { zout = getArchiveOutputStream(archiveFile); if (useCompression) { zout.setMethod(ZipEntry.DEFLATED); zout.setLevel(9); } else { zout.setMethod(ZipEntry.STORED); zout.setLevel(0); } this.verbose = verbose; }
/** * Creates a single-entry zip file. * * @param input an uncompressed file * @param pathWithinArchive the path within the archive * @param output the new zip file it will be compressed into */ public static void zip(File input, String pathWithinArchive, File output) throws IOException { try (ZipOutputStream zipStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(output)))) { zipStream.setMethod(ZipOutputStream.DEFLATED); zipStream.setLevel(9); zipStream.putNextEntry(new ZipEntry(pathWithinArchive)); try (BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(input))) { copy(inputStream, zipStream); } } }
public ZipBuilder(File archiveFile, boolean useCompression, boolean verbose) throws IOException { zout = getArchiveOutputStream(archiveFile); if (useCompression) { zout.setMethod(ZipEntry.DEFLATED); zout.setLevel(9); } else { zout.setMethod(ZipEntry.STORED); zout.setLevel(0); } this.verbose = verbose; }
/** * Intermediate operation during ip creation * @param method * @param level * @param buf * @param resources * @throws IOException */ private static void zipCore(int method, int level, BufferedOutputStream buf, Path[] resources) throws IOException { try (final ZipOutputStream zout = new ZipOutputStream(buf)) { zout.setMethod(method); zout.setLevel(level); zipCore(zout, method, level, "", Arrays.asList(resources).iterator()); } }
/** * */ public void zipEntries(OutputStream os) throws IOException { ZipOutputStream zipos = new ZipOutputStream(os); zipos.setMethod(ZipOutputStream.DEFLATED); for (int i = 0; i < exportZipEntries.size(); i++) { ExportZipEntry oasisZipEntry = (ExportZipEntry)exportZipEntries.get(i); ZipEntry zipEntry = new ZipEntry(oasisZipEntry.getName()); zipos.putNextEntry(zipEntry); oasisZipEntry.writeData(zipos); } zipos.flush(); zipos.finish(); }
/** * @see DefaultHandler#exportData(ExportContext,boolean,Node) */ @Override protected void exportData(ExportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException { ZipOutputStream zout = new ZipOutputStream(context.getOutputStream()); zout.setMethod(ZipOutputStream.DEFLATED); try { int pos = contentNode.getPath().length(); exportZipEntry(context, zout, contentNode, pos > 1 ? pos+1 : pos); } finally { zout.finish(); } }
private static void buildThemeZipFile(File zipPath, ResTable resTable) { try { FileOutputStream fos = new FileOutputStream(zipPath); ZipOutputStream outStream = new ZipOutputStream(new BufferedOutputStream(fos)); outStream.setMethod(ZipOutputStream.STORED); ByteArrayOutputStream byteArrOS = new ByteArrayOutputStream(); ArscWriter writer = new ArscWriter(resTable); writer.write(byteArrOS); byte[] bytes = byteArrOS.toByteArray(); ZipEntry entry = new ZipEntry("resources.arsc"); entry.setSize(bytes.length); CRC32 crc = new CRC32(); crc.update(bytes); entry.setCrc(crc.getValue()); outStream.putNextEntry(entry); outStream.write(bytes); outStream.close(); fos.close(); } catch (IOException e) { e.printStackTrace(); } }
public void writeContent( final ZipEntry entry, final InputStream in, final int method, final int compression ) throws IOException { zipOutputStream.setMethod( method ); zipOutputStream.setLevel( compression ); zipOutputStream.putNextEntry( entry ); IOUtils.getInstance().copyStreams( in, zipOutputStream ); zipOutputStream.closeEntry(); } }
@Override public void writeModel(OutputStream out, Model[] models) throws IOException { ZipOutputStream zip = new ZipOutputStream(out); zip.setMethod(ZipOutputStream.STORED); for (int i = 0; i < models.length; i++) { ZipEntry zipEntry = new ZipEntry("model" + i + ".ctm"); ByteArrayOutputStream buf = new ByteArrayOutputStream(); writeSingleModel(buf, models[i]); byte[] toByteArray = buf.toByteArray(); CRC32 c = new CRC32(); c.update(toByteArray); zipEntry.setSize(toByteArray.length); zipEntry.setCompressedSize(toByteArray.length); zipEntry.setCrc(c.getValue()); zip.putNextEntry(zipEntry); zip.write(toByteArray); zip.closeEntry(); } zip.finish(); }