public ZipMultiChunk(MultiChunkId id, int minSize, OutputStream os) throws IOException { super(id, minSize); this.zipOut = new ZipOutputStream(os); this.zipOut.setLevel(ZipOutputStream.STORED); // No compression }
private RepackZipEntryCallback(File dstZip, int compressionLevel) { try { this.out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(dstZip))); this.out.setLevel(compressionLevel); } catch (IOException e) { ZipExceptionUtil.rethrow(e); } }
public void done() throws IOException { ZipOutputStream zip = null; try { zip = new ZipOutputStream(new BufferedOutputStream(destinationStream)); zip.setLevel(level); for (Map.Entry<String, File> zipDirToSourceFileEntry : toAdd.entrySet()) { File sourceFileToZip = zipDirToSourceFileEntry.getValue(); String destinationFolder = zipDirToSourceFileEntry.getKey(); zipUtil.addToZip(new ZipPath(destinationFolder), sourceFileToZip, zip, excludeRootDir); } zip.flush(); } finally { if (zip != null) { try { zip.close(); } catch (IOException e) { LOGGER.error("Failed to close the stream", e); } } } } }
public void writeObject(ByteBuffer buffer, Object object) throws IOException { if (!(object instanceof ZIPCompressedMessage)) return; ZIPCompressedMessage zipMessage = (ZIPCompressedMessage)object; Message message = zipMessage.getMessage(); ByteBuffer tempBuffer = ByteBuffer.allocate(512000); Serializer.writeClassAndObject(tempBuffer, message); ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream(); ZipOutputStream zipOutput = new ZipOutputStream(byteArrayOutput); zipOutput.setLevel(zipMessage.getLevel()); ZipEntry zipEntry = new ZipEntry("zip"); zipOutput.putNextEntry(zipEntry); tempBuffer.flip(); zipOutput.write(tempBuffer.array(), 0, tempBuffer.limit()); zipOutput.flush(); zipOutput.closeEntry(); zipOutput.close(); buffer.put(byteArrayOutput.toByteArray()); } }
/** * @param bytes Byte array to compress. * @param compressionLevel Level of compression to encode. * @return Compressed bytes. * @throws IgniteCheckedException If failed. */ public static byte[] zip(@Nullable byte[] bytes, int compressionLevel) throws IgniteCheckedException { try { if (bytes == null) return null; ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (ZipOutputStream zos = new ZipOutputStream(bos)) { zos.setLevel(compressionLevel); ZipEntry entry = new ZipEntry(""); try { entry.setSize(bytes.length); zos.putNextEntry(entry); zos.write(bytes); } finally { zos.closeEntry(); } } return bos.toByteArray(); } catch (Exception e) { throw new IgniteCheckedException(e); } }
zos.setLevel(9); indexFile = new File(filename + ".inx"); // Index file if(!indexFile.exists()){
public CopyBuggySource(String[] args) throws Exception { origCollection = new SortedBugCollection(); origCollection.readXML(args[0]); project = origCollection.getProject(); sourceFinder = new SourceFinder(project); src = new File(args[1]); kind = SrcKind.get(src); switch (kind) { case DIR: break; case ZIP: zOut = new ZipOutputStream(new FileOutputStream(src)); break; case Z0P_GZ: zOut = new ZipOutputStream(new DeflaterOutputStream(new FileOutputStream(src))); zOut.setLevel(0); break; } }
try { out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(targetZip))); out.setLevel(compressionLevel); pack(sourceDir, out, mapper, "", true);
output.setLevel(Deflater.DEFAULT_COMPRESSION); } else { output.setMethod(ZipOutputStream.STORED);
try { out = new ZipOutputStream(new BufferedOutputStream(os)); out.setLevel(compressionLevel); pack(sourceDir, out, mapper, "", true);
@Override public void process(final OutputStream rawOut) throws IOException { try (final OutputStream bufferedOut = new BufferedOutputStream(rawOut); final ZipOutputStream out = new ZipOutputStream(bufferedOut)) { out.setLevel(compressionLevel); for (final FlowFile flowFile : contents) { final String path = keepPath ? getPath(flowFile) : ""; final String entryName = path + flowFile.getAttribute(CoreAttributes.FILENAME.key()); final ZipEntry zipEntry = new ZipEntry(entryName); zipEntry.setSize(flowFile.getSize()); try { out.putNextEntry(zipEntry); bin.getSession().exportTo(flowFile, out); out.closeEntry(); unmerged.remove(flowFile); } catch (ZipException e) { getLogger().error("Encountered exception merging {}", new Object[] {flowFile}, e); } } out.finish(); out.flush(); } } });
fos = new FileOutputStream(destZipFile); out = new ZipOutputStream(new BufferedOutputStream(fos)); out.setLevel(compressionLevel);
zos.setLevel(dsCfg.getWalCompactionLevel()); zos.putNextEntry(new ZipEntry(nextSegment + ".wal"));
out.setLevel( Deflater.BEST_COMPRESSION );
zipOutputStream.setLevel(9); // best compression to reduce the amount of data to stream over the wire
zipOutputStream.setLevel(ZipOutputStream.STORED);
public ZipGenerator(String filename) throws FileNotFoundException { dest = new FileOutputStream(filename); out = new ZipOutputStream(new BufferedOutputStream(dest)); out.setLevel(Deflater.BEST_COMPRESSION); }
public void addMimeTypeFile(String statedPath, String actualPath) throws IOException { // byte data[] = new byte[BUFFER]; CRC32 crc = new CRC32(); // FileInputStream fi = new FileInputStream(actualPath); // BufferedInputStream origin = new BufferedInputStream(fi, BUFFER); out.setLevel(0); ZipEntry entry = new ZipEntry(statedPath); entry.setExtra(null); names.add(statedPath); String contents = "application/epub+zip"; crc.update(contents.getBytes()); entry.setCompressedSize(contents.length()); entry.setSize(contents.length()); entry.setCrc(crc.getValue()); entry.setMethod(ZipEntry.STORED); out.putNextEntry(entry); // int count; // while ((count = origin.read(data, 0, BUFFER)) != -1) { // out.write(data, 0, count); // } // origin.close(); out.write(contents.getBytes(),0,contents.length()); out.setLevel(Deflater.BEST_COMPRESSION); }
@Override public void begin() { super.begin(); try { m_zipOutputStream = new ZipOutputStream(new FileOutputStream(m_tempFile)); m_zipOutputStream.setLevel(9); } catch (final Exception e) { LOG.error("Unable to create zip file '{}'", m_tempFile, e); return; } }