當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。