Java Code Examples for java.util.zip.Deflater#DEFAULT_COMPRESSION
The following examples show how to use
java.util.zip.Deflater#DEFAULT_COMPRESSION .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZipContentItem.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public ZipContentItem( final ZipRepository repository, final ZipContentLocation parent, final String name ) { if ( repository == null ) { throw new NullPointerException(); } if ( parent == null ) { throw new NullPointerException(); } if ( name == null ) { throw new NullPointerException(); } this.repository = repository; this.parent = parent; this.entryName = name; this.name = RepositoryUtilities.buildName( this, "/" ); this.time = System.currentTimeMillis(); this.comment = null; this.size = 0; this.rawData = EMPTY_BYTES; this.method = LibRepositoryBoot.ZIP_METHOD_DEFLATED; this.compression = Deflater.DEFAULT_COMPRESSION; }
Example 2
Source File: DeflateUncompressorTest.java From archive-patcher with Apache License 2.0 | 6 votes |
@Test public void testNowrap() throws IOException { // Recompress with nowrap set to false. Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, false /* nowrap */); ByteArrayOutputStream compressedContentBuffer = new ByteArrayOutputStream(); DeflaterOutputStream deflateOut = new DeflaterOutputStream(compressedContentBuffer, deflater); deflateOut.write(CONTENT); deflateOut.finish(); deflateOut.close(); deflater.end(); compressedContent = compressedContentBuffer.toByteArray(); compressedContentIn = new ByteArrayInputStream(compressedContent); // Now expect wrapped content in the uncompressor, and uncompressing should "just work". uncompressor.setNowrap(false); uncompressor.uncompress(compressedContentIn, uncompressedContentOut); assertTrue(Arrays.equals(CONTENT, uncompressedContentOut.toByteArray())); }
Example 3
Source File: PBFOutput.java From osm-lib with BSD 2-Clause "Simplified" License | 6 votes |
/** * Deflate the given input data buffer into the given output byte buffer. * Used in both PBF and VEX output. * @return the deflated size of the data, or -1 if deflate did not reduce the data size. */ public static int deflate (byte[] input, byte[] output) { int pos = 0; // Do not compress an empty data block, it will spin forever trying to fill the zero-length output buffer. if (input.length > 0) { Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, false); // include gzip header and checksum deflater.setInput(input, 0, input.length); deflater.finish(); // There will be no more input after this byte array. while (!deflater.finished()) { pos += deflater.deflate(output, pos, output.length - pos, Deflater.SYNC_FLUSH); if (pos >= input.length) { return -1; // compressed output is bigger than buffer, store uncompressed } } } return pos; }
Example 4
Source File: ZipFileSystem.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private Deflater getDeflater() { synchronized (deflaters) { int size = deflaters.size(); if (size > 0) { Deflater def = deflaters.remove(size - 1); return def; } else { return new Deflater(Deflater.DEFAULT_COMPRESSION, true); } } }
Example 5
Source File: ZipFileSystem.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private Deflater getDeflater() { synchronized (deflaters) { int size = deflaters.size(); if (size > 0) { Deflater def = deflaters.remove(size - 1); return def; } else { return new Deflater(Deflater.DEFAULT_COMPRESSION, true); } } }
Example 6
Source File: ZipFileSystem.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private Deflater getDeflater() { synchronized (deflaters) { int size = deflaters.size(); if (size > 0) { Deflater def = deflaters.remove(size - 1); return def; } else { return new Deflater(Deflater.DEFAULT_COMPRESSION, true); } } }
Example 7
Source File: ZipFileSystem.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private Deflater getDeflater() { synchronized (deflaters) { int size = deflaters.size(); if (size > 0) { Deflater def = deflaters.remove(size - 1); return def; } else { return new Deflater(Deflater.DEFAULT_COMPRESSION, true); } } }
Example 8
Source File: ZipFileSystem.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private Deflater getDeflater() { synchronized (deflaters) { int size = deflaters.size(); if (size > 0) { Deflater def = deflaters.remove(size - 1); return def; } else { return new Deflater(Deflater.DEFAULT_COMPRESSION, true); } } }
Example 9
Source File: ApkBreakdownGeneratorTest.java From bundletool with Apache License 2.0 | 5 votes |
@Test public void checkDeflaterSyncOverheadCorrect() throws Exception { Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, /* noWrap */ true); byte[] output = new byte[100]; assertThat(deflater.deflate(output, 0, output.length, Deflater.SYNC_FLUSH)) .isEqualTo(ApkCompressedSizeCalculator.DEFLATER_SYNC_OVERHEAD_BYTES); }
Example 10
Source File: ParallelGZIPOutputStream.java From parallelgzip with Apache License 2.0 | 4 votes |
@Nonnull private static Deflater newDeflater() { return new Deflater(Deflater.DEFAULT_COMPRESSION, true); }
Example 11
Source File: ZlibXmppCompressionFactory.java From Smack with Apache License 2.0 | 4 votes |
private ZlibXmppInputOutputFilter() { this(Deflater.DEFAULT_COMPRESSION); }
Example 12
Source File: ZipRepository.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public ZipRepository( final OutputStream out ) { this( out, Deflater.DEFAULT_COMPRESSION, new DefaultMimeRegistry() ); }
Example 13
Source File: GzipEncodingProvider.java From lams with GNU General Public License v2.0 | 4 votes |
public GzipEncodingProvider() { this(Deflater.DEFAULT_COMPRESSION); }
Example 14
Source File: DeflateCompressor.java From nv-websocket-client with Apache License 2.0 | 4 votes |
private static Deflater createDeflater() { // The second argument (nowrap) is true to get only DEFLATE // blocks without the ZLIB header and checksum fields. return new Deflater(Deflater.DEFAULT_COMPRESSION, true); }
Example 15
Source File: GzipCompressingInputStream.java From galaxy-fds-sdk-java with Apache License 2.0 | 4 votes |
public InternalGzipCompressingInputStream(CRC32InputStream in, int bufferSize) { super(in, new Deflater(Deflater.DEFAULT_COMPRESSION, true), bufferSize); crcIn = in; }
Example 16
Source File: XJarDecryptor.java From xjar with Apache License 2.0 | 4 votes |
public XJarDecryptor(XDecryptor xDecryptor, XEntryFilter<JarArchiveEntry> filter) { this(xDecryptor, Deflater.DEFAULT_COMPRESSION, filter); }
Example 17
Source File: GzipCompressingInputStream.java From simplewebserver with Apache License 2.0 | 4 votes |
public InternalGzipCompressingInputStream(CRC32InputStream in, int bufferSize) { super(in, new Deflater(Deflater.DEFAULT_COMPRESSION, true), bufferSize); crcIn = in; }
Example 18
Source File: XZipEncryptor.java From xjar with Apache License 2.0 | 4 votes |
public XZipEncryptor(XEncryptor xEncryptor, XEntryFilter<ZipArchiveEntry> filter) { this(xEncryptor, Deflater.DEFAULT_COMPRESSION, filter); }
Example 19
Source File: CompressedBlockOutputStream.java From blucat with GNU General Public License v2.0 | 2 votes |
/** * Constructs a CompressedBlockOutputStream that writes to * the given underlying output stream 'os' and sends a compressed * block once 'size' byte have been written. The default * compression strategy and level are used. */ public CompressedBlockOutputStream(OutputStream os, int size) throws IOException { this(os, size, Deflater.DEFAULT_COMPRESSION, Deflater.DEFAULT_STRATEGY); }
Example 20
Source File: ReusableGzipOutputStream.java From xian with Apache License 2.0 | 2 votes |
/** * Creates a new output stream with the specified buffer size and flush mode. * * @param out the output stream * @exception IOException If an I/O error has occurred. * @exception IllegalArgumentException if {@code size <= 0} * * @since 1.7 */ public ReusableGzipOutputStream(OutputStream out) throws IOException { super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true)); crc.reset(); }