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


Java Deflater.BEST_COMPRESSION属性代码示例

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


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

示例1: dumpFlate

/** Write the entire content into the given file using Flate compression (see RFC1951) then return the number of bytes written. */
public long dumpFlate(RandomAccessFile os) throws IOException {
   Deflater zip = new Deflater(Deflater.BEST_COMPRESSION);
   byte[] output = new byte[8192];
   Iterator<byte[]> it = list.iterator(); // when null, that means we have told the Deflater that no more input would be coming
   long ans = 0; // the number of bytes written out so far
   while(true) {
      if (it!=null && zip.needsInput() && it.hasNext()) {
         byte[] in = it.next();
         if (in == list.getLast()) { zip.setInput(in, 0, n); it=null; zip.finish(); } else { zip.setInput(in, 0, SIZE); }
      }
      if (it==null && zip.finished()) break;
      int count = zip.deflate(output);
      if (count > 0) {
         ans = ans + count;
         if (ans < 0) throw new IOException("Data too large to be written to the output file.");
         os.write(output, 0, count);
      }
   }
   return ans;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:ByteBuffer.java

示例2: 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

示例3: ZioEntryOutputStream

public ZioEntryOutputStream( int compression, OutputStream wrapped) 
{
    this.wrapped = wrapped;
    if (compression != 0)
        downstream = new DeflaterOutputStream( wrapped, new Deflater( Deflater.BEST_COMPRESSION, true));
    else downstream = wrapped;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:7,代码来源:ZioEntryOutputStream.java

示例4: dumpFlate

/**
 * Write the entire content into the given file using Flate compression (see
 * RFC1951) then return the number of bytes written.
 */
public long dumpFlate(RandomAccessFile os) throws IOException {
	Deflater zip = new Deflater(Deflater.BEST_COMPRESSION);
	byte[] output = new byte[8192];
	Iterator<byte[]> it = list.iterator(); // when null, that means we have
											// told the Deflater that no
											// more input would be coming
	long ans = 0; // the number of bytes written out so far
	while (true) {
		if (it != null && zip.needsInput() && it.hasNext()) {
			byte[] in = it.next();
			if (in == list.getLast()) {
				zip.setInput(in, 0, n);
				it = null;
				zip.finish();
			} else {
				zip.setInput(in, 0, SIZE);
			}
		}
		if (it == null && zip.finished())
			break;
		int count = zip.deflate(output);
		if (count > 0) {
			ans = ans + count;
			if (ans < 0)
				throw new IOException("Data too large to be written to the output file.");
			os.write(output, 0, count);
		}
	}
	return ans;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:34,代码来源:ByteBuffer.java

示例5: writeZTXT

private void writeZTXT() throws IOException
{
	if (param.isCompressedTextSet())
	{
		String[] text = param.getCompressedText();

		for (int i = 0; i < text.length / 2; i++)
		{
			byte[] keyword = text[2 * i].getBytes();
			byte[] value = text[2 * i + 1].getBytes();

			ChunkStream cs = new ChunkStream("zTXt");

			cs.write(keyword, 0, Math.min(keyword.length, 79));
			cs.write(0);
			cs.write(0);

			DeflaterOutputStream dos = new DeflaterOutputStream(cs,
					new Deflater(Deflater.BEST_COMPRESSION, true));
			dos.write(value);
			dos.finish();

			cs.writeToStream(dataOutput);
			cs.close();
		}
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:27,代码来源:mxPngImageEncoder.java

示例6: serialise

@Override
public JSONObject serialise() {
    JSONObject json = new JSONObject();

    byte[] terrain = new byte[width * width];

    for (int x = 0; x < World.WORLD_SIZE; x++) {
        for (int y = 0; y < World.WORLD_SIZE; y++) {
            terrain[x * width + y] = (byte) tiles[x][y];
        }
    }
    try {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        Deflater compressor = new Deflater(Deflater.BEST_COMPRESSION, true);
        DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(stream, compressor);

        deflaterOutputStream.write(terrain);

        deflaterOutputStream.close();
        byte[] compressedBytes = stream.toByteArray();

        json.put("z", new String(Base64.getEncoder().encode(compressedBytes)));

    } catch (IOException e) {
        e.printStackTrace();
    }

    return json;
}
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:29,代码来源:TileMap.java

示例7: 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

示例8: ZMBVVideoCodec

public ZMBVVideoCodec(int height, Font terminalFont, Object object,
		boolean allowBold) {
	super(height, terminalFont, object, allowBold);
	deflater = new Deflater(Deflater.BEST_COMPRESSION);
}
 
开发者ID:Elronnd,项目名称:ttyrec2video,代码行数:5,代码来源:ZMBVVideoCodec.java

示例9: getLevel

/**
 * Returns the compression level to use when writing a GZIP sink stream.
 * <p>
 * The implementation in the class {@link TarGZipDriver} returns
 * {@link Deflater#BEST_COMPRESSION}.
 *
 * @return The compression level to use when writing a GZIP sink stream.
 */
public int getLevel() {
    return Deflater.BEST_COMPRESSION;
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:11,代码来源:TarGZipDriver.java

示例10: getLevel

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


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