本文整理汇总了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);
}
}
示例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;
}
示例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;
}
}
示例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();
}
}
示例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);
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例9: CompressWrapper
public CompressWrapper() {
this.wrapBuffer = new ByteArrayOutputStream();
this.unwrapBuffer = new ByteArrayOutputStream();
this.deflater = new Deflater(Deflater.BEST_SPEED);
this.inflater = new Inflater();
}
示例10: getLevel
@Override
public int getLevel() {
return Deflater.BEST_SPEED;
}