本文整理汇总了Java中net.jpountz.lz4.LZ4BlockOutputStream.close方法的典型用法代码示例。如果您正苦于以下问题:Java LZ4BlockOutputStream.close方法的具体用法?Java LZ4BlockOutputStream.close怎么用?Java LZ4BlockOutputStream.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.jpountz.lz4.LZ4BlockOutputStream
的用法示例。
在下文中一共展示了LZ4BlockOutputStream.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compress
import net.jpountz.lz4.LZ4BlockOutputStream; //导入方法依赖的package包/类
@Override
public byte[] compress( final byte[] data , final int start , final int length ) throws IOException{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
bOut.write( LENGTH_DUMMY , 0 , LENGTH_DUMMY.length );
LZ4BlockOutputStream out = new LZ4BlockOutputStream( bOut );
out.write( data , start , length );
out.flush();
out.finish();
byte[] compressByte = bOut.toByteArray();
ByteBuffer.wrap( compressByte ).putInt( length );
bOut.close();
out.close();
return compressByte;
}
示例2: serializeCompressLZ4
import net.jpountz.lz4.LZ4BlockOutputStream; //导入方法依赖的package包/类
public synchronized int serializeCompressLZ4(T obj, File file) {
try {
byte[] barray = conf.get().asByteArray(obj);
int compressedLength = barray.length;
int decompressedLength = -1;
// Notes: uses an LZ4 block size of 64KB, fast compressor
LZ4BlockOutputStream LZOS = new LZ4BlockOutputStream(new FileOutputStream(file));
FSTObjectOutput oos = conf.get().getObjectOutput(LZOS);
oos.writeObject(obj);
oos.flush();
LZOS.close();
return decompressedLength;
}
catch(Exception e) {
e.printStackTrace();
}
return -1;
}
示例3: compress
import net.jpountz.lz4.LZ4BlockOutputStream; //导入方法依赖的package包/类
@Override
public byte[] compress(byte[] data) throws IOException {
LZ4Factory factory = LZ4Factory.fastestInstance();
ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
LZ4Compressor compressor = factory.fastCompressor();
LZ4BlockOutputStream compressedOutput = new LZ4BlockOutputStream(byteOutput, 2048, compressor);
compressedOutput.write(data);
compressedOutput.close();
return byteOutput.toByteArray();
}
示例4: compress
import net.jpountz.lz4.LZ4BlockOutputStream; //导入方法依赖的package包/类
public static byte[] compress(byte srcBytes[]) throws IOException {
LZ4Factory factory = LZ4Factory.fastestInstance();
ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
LZ4Compressor compressor = factory.fastCompressor();
LZ4BlockOutputStream compressedOutput = new LZ4BlockOutputStream(
byteOutput, 2048, compressor);
compressedOutput.write(srcBytes);
compressedOutput.close();
return byteOutput.toByteArray();
}