当前位置: 首页>>代码示例>>Java>>正文


Java Deflater.DEFAULT_COMPRESSION属性代码示例

本文整理汇总了Java中java.util.zip.Deflater.DEFAULT_COMPRESSION属性的典型用法代码示例。如果您正苦于以下问题:Java Deflater.DEFAULT_COMPRESSION属性的具体用法?Java Deflater.DEFAULT_COMPRESSION怎么用?Java Deflater.DEFAULT_COMPRESSION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.util.zip.Deflater的用法示例。


在下文中一共展示了Deflater.DEFAULT_COMPRESSION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compress

private static byte[] compress(byte[] data) throws IOException {
	Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
	deflater.setInput(data);
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
	deflater.finish();
	byte[] buffer = new byte[1024];
	while (!deflater.finished()) {
		int count = deflater.deflate(buffer);
		outputStream.write(buffer, 0, count);
	}
	outputStream.close();
	byte[] output = outputStream.toByteArray();
	Log.d("Compressor", "Original: " + data.length);
	Log.d("Compressor", "Compressed: " + output.length);
	return output;
}
 
开发者ID:SapuSeven,项目名称:NotiCap,代码行数:16,代码来源:Compressor.java

示例2: openFile

protected void openFile() {

        try {
            FileAccess           fa  = database.getFileAccess();
            java.io.OutputStream fos = fa.openOutputStreamElement(outFile);

            outDescriptor = fa.getFileSync(fos);
            fileStreamOut = new DeflaterOutputStream(fos,
                    new Deflater(Deflater.DEFAULT_COMPRESSION), bufferSize);
        } catch (IOException e) {
            throw Error.error(ErrorCode.FILE_IO_ERROR,
                              ErrorCode.M_Message_Pair, new Object[] {
                e.toString(), outFile
            });
        }
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:16,代码来源:ScriptWriterZipped.java

示例3: testNowrap

@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()));
}
 
开发者ID:lizhangqu,项目名称:CorePatch,代码行数:18,代码来源:DeflateUncompressorTest.java

示例4: openFile

protected void openFile() throws HsqlException {

        try {
            FileAccess           fa  = database.getFileAccess();
            java.io.OutputStream fos = fa.openOutputStreamElement(outFile);

            outDescriptor = fa.getFileSync(fos);
            fileStreamOut = new DeflaterOutputStream(fos,
                    new Deflater(Deflater.DEFAULT_COMPRESSION), bufferSize);
        } catch (IOException e) {
            throw Trace.error(Trace.FILE_IO_ERROR, Trace.Message_Pair,
                              new Object[] {
                e.toString(), outFile
            });
        }
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:ScriptWriterZipped.java

示例5: TIFFDeflater

public TIFFDeflater(String compressionType,
                    int compressionTagValue,
                    ImageWriteParam param,
                    int predictorValue) {
    super(compressionType, compressionTagValue, true);

    this.predictor = predictorValue;

    // Set the deflate level.
    int deflateLevel;
    if(param != null &&
       param.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT) {
        float quality = param.getCompressionQuality();
        deflateLevel = (int)(1 + 8*quality);
    } else {
        deflateLevel = Deflater.DEFAULT_COMPRESSION;
    }

    this.deflater = new Deflater(deflateLevel);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:TIFFDeflater.java

示例6: getContentPayload

@Override
public byte[] getContentPayload() {
	byte[] payload = new byte[(width+1)*height];
	for(int i = 0; i<height ; i++) {
		int offset = i * (width+1);
		//NO filter on this line
		payload[offset++] = 0;
		for(int j = 0 ; j<width ; j++) {
			payload[offset+j] = (byte)(127);
		}
	}

	Deflater deflater = new Deflater( Deflater.DEFAULT_COMPRESSION );
    ByteArrayOutputStream outBytes = new ByteArrayOutputStream((width+1)*height);

    DeflaterOutputStream compBytes = new DeflaterOutputStream( outBytes, deflater );
    try {
    	compBytes.write(payload);
    	compBytes.close();
    } catch(Exception e) {
    	e.printStackTrace();
    }
    byte[] compPayload = outBytes.toByteArray();

	return compPayload;
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:26,代码来源:IDATChunk.java

示例7: getZipCompressionLevel

private int getZipCompressionLevel(FuzzyCompressionLevel compressionLevel) {
	switch (compressionLevel) {
		case BEST:
			return Deflater.BEST_COMPRESSION;
		case FASTEST:
			return Deflater.BEST_SPEED;
		case NONE:
			return Deflater.NO_COMPRESSION;
		case DEFAULT:
		default:
			return Deflater.DEFAULT_COMPRESSION;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:13,代码来源:ZipFileObject.java

示例8: setUp

@Before
public void setUp() throws IOException {
  ByteArrayOutputStream compressedContentBuffer = new ByteArrayOutputStream();
  Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
  DeflaterOutputStream deflateOut = new DeflaterOutputStream(compressedContentBuffer, deflater);
  deflateOut.write(CONTENT);
  deflateOut.finish();
  deflateOut.close();
  deflater.end();
  compressedContent = compressedContentBuffer.toByteArray();
  uncompressor = new DeflateUncompressor();
  compressedContentIn = new ByteArrayInputStream(compressedContent);
  uncompressedContentOut = new ByteArrayOutputStream();
}
 
开发者ID:lizhangqu,项目名称:CorePatch,代码行数:14,代码来源:DeflateUncompressorTest.java

示例9: openFile

protected void openFile() throws HsqlException {

        try {
            FileOutputStream fos = new FileOutputStream(outFile, true);

            outDescriptor = fos.getFD();
            fileStreamOut = new DeflaterOutputStream(fos,
                    new Deflater(Deflater.DEFAULT_COMPRESSION), bufferSize);
        } catch (IOException e) {
            throw Trace.error(Trace.FILE_IO_ERROR, Trace.Message_Pair,
                              new Object[] {
                e.getMessage(), outFile
            });
        }
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:ScriptWriterZipped.java

示例10: getDeflater

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);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:ZipFileSystem.java

示例11: setLevel0

private void setLevel0(int level) {
    if ((level < Deflater.NO_COMPRESSION || Deflater.BEST_COMPRESSION < level)
            && level != Deflater.DEFAULT_COMPRESSION)
        throw new IllegalArgumentException("Invalid compression level!");
    this.level = level;
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:6,代码来源:AbstractZipOutputStream.java

示例12: GzipStreamSinkConduit

public GzipStreamSinkConduit(ConduitFactory<StreamSinkConduit> conduitFactory, HttpServerExchange exchange) {
    super(conduitFactory, exchange, Deflater.DEFAULT_COMPRESSION);
    writeHeader();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:GzipStreamSinkConduit.java

示例13: createDeflater

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);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:6,代码来源:DeflateCompressor.java

示例14: ZipOutputStream

/**
 * Creates a new ZIP output stream.
 *
 * @param out the actual output stream
 */
public ZipOutputStream(OutputStream out) {
	super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true));
	usesDefaultDeflater = true;
}
 
开发者ID:funtl,项目名称:framework,代码行数:9,代码来源:ZipOutputStream.java

示例15: getLevel

/**
 * {@inheritDoc}
 * <p>
 * The implementation in the class {@link DefaultZipOutputStreamParameters}
 * returns {@code Deflater#DEFAULT_COMPRESSION}.
 */
@Override
public int getLevel() {
    return Deflater.DEFAULT_COMPRESSION;
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:10,代码来源:DefaultZipOutputStreamParameters.java


注:本文中的java.util.zip.Deflater.DEFAULT_COMPRESSION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。