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


Java Deflater.BEST_SPEED属性代码示例

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


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

示例1: storeData

private void storeData(ByteBuffer data) {
    try {
        final byte[] input = data.array();
        FileOutputStream fos = new FileOutputStream(file);

        final Deflater deflater = new Deflater(Deflater.BEST_SPEED, true);
        deflater.setInput(input, data.arrayOffset(), data.remaining());
        deflater.finish();

        byte[] buf = new byte[1024];
        while (!deflater.finished()) {
            int byteCount = deflater.deflate(buf);
            fos.write(buf, 0, byteCount);
        }
        deflater.end();

        fos.close();
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:21,代码来源:Slice.java

示例2: mongoSerialise

@Override
public BasicDBObject mongoSerialise() {

    BasicDBObject dbObject = new BasicDBObject();

    try {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        Deflater compressor = new Deflater(Deflater.BEST_SPEED, true);
        DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(stream, compressor);
        deflaterOutputStream.write(getBytes());
        deflaterOutputStream.close();
        byte[] compressedBytes = stream.toByteArray();

        dbObject.put("zipBytes", new String(Base64.getEncoder().encode(compressedBytes)));

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

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

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

示例4: open

public void open() {

        lobBlockSize = database.logger.getLobBlockSize();
        cryptLobs    = database.logger.cryptLobs;
        compressLobs = database.logger.propCompressLobs;

        if (compressLobs || cryptLobs) {
            int largeBufferBlockSize = largeLobBlockSize + 4 * 1024;

            inflater   = new Inflater();
            deflater   = new Deflater(Deflater.BEST_SPEED);
            dataBuffer = new byte[largeBufferBlockSize];
        }

        if (database.getType() == DatabaseType.DB_RES) {
            lobStore = new LobStoreInJar(database, lobBlockSize);
        } else if (database.getType() == DatabaseType.DB_FILE) {
            lobStore = new LobStoreRAFile(database, lobBlockSize);

            if (!database.isFilesReadOnly()) {
                byteBuffer = new byte[lobBlockSize];

                initialiseLobSpace();
            }
        } else {
            lobStore   = new LobStoreMem(lobBlockSize);
            byteBuffer = new byte[lobBlockSize];

            initialiseLobSpace();
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:31,代码来源:LobManager.java

示例5: write

@Override
public final void write(DataOutput out) throws IOException {
  if (compressed == null) {
    ByteArrayOutputStream deflated = new ByteArrayOutputStream();
    Deflater deflater = new Deflater(Deflater.BEST_SPEED);
    DataOutputStream dout =
      new DataOutputStream(new DeflaterOutputStream(deflated, deflater));
    writeCompressed(dout);
    dout.close();
    deflater.end();
    compressed = deflated.toByteArray();
  }
  out.writeInt(compressed.length);
  out.write(compressed);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:CompressedWritable.java

示例6: deflate

public static byte[] deflate(byte[] input) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    Deflater deflater = new Deflater(Deflater.BEST_SPEED);
    deflater.setInput(input);
    deflater.finish();

    byte[] intermediate = new byte[1024];
    while (!deflater.finished()) {
        int read = deflater.deflate(intermediate);
        out.write(intermediate, 0, read);
    }

    return out.toByteArray();
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:15,代码来源:ByteBufUtils.java

示例7: _zipToBytes

/**
 * Returned the zipped version of the viewState
 */
private byte[] _zipToBytes(Object viewState)
{
  Deflater compresser = new Deflater(Deflater.BEST_SPEED);

  try
  {
    //Serialize state
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(viewState);
    oos.flush();
    oos.close();

    byte[] ret =  baos.toByteArray();
    compresser.setInput(ret);
    compresser.finish();

    baos.reset();
    byte[] buf = new byte[ret.length/5];

    while (!compresser.finished())
    {
      int count = compresser.deflate(buf);
      baos.write(buf, 0, count);
    }

    return baos.toByteArray();
  }
  catch (IOException e)
  {
    throw new RuntimeException(_LOG.getMessage("ZIP_STATE_FAILED"), e);
  }
  finally
  {
    compresser.end();
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:41,代码来源:StateManagerImpl.java

示例8: open

public void open() {

        lobBlockSize = database.logger.getLobBlockSize();
        cryptLobs    = database.logger.cryptLobs;
        compressLobs = database.logger.propCompressLobs;

        if (compressLobs || cryptLobs) {
            int largeBufferBlockSize = largeLobBlockSize + 4 * 1024;

            inflater   = new Inflater();
            deflater   = new Deflater(Deflater.BEST_SPEED);
            dataBuffer = new byte[largeBufferBlockSize];
        }

        if (database.getType() == DatabaseURL.S_RES) {
            lobStore = new LobStoreInJar(database, lobBlockSize);
        } else if (database.getType() == DatabaseURL.S_FILE) {
            lobStore = new LobStoreRAFile(database, lobBlockSize);

            if (!database.isFilesReadOnly()) {
                byteBuffer = new byte[lobBlockSize];

                initialiseLobSpace();
            }
        } else {
            lobStore   = new LobStoreMem(lobBlockSize);
            byteBuffer = new byte[lobBlockSize];

            initialiseLobSpace();
        }
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:31,代码来源:LobManager.java

示例9: CompressWrapper

public CompressWrapper() {
    this.wrapBuffer = new ByteArrayOutputStream();
    this.unwrapBuffer = new ByteArrayOutputStream();
    this.deflater = new Deflater(Deflater.BEST_SPEED);
    this.inflater = new Inflater();
}
 
开发者ID:ZhangJiupeng,项目名称:AgentX,代码行数:6,代码来源:CompressWrapper.java

示例10: getLevel

@Override
public int getLevel() {
    return Deflater.BEST_SPEED;
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:4,代码来源:TestTarGZipDriver.java


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