本文整理汇总了Java中org.meteogroup.jbrotli.BrotliStreamCompressor类的典型用法代码示例。如果您正苦于以下问题:Java BrotliStreamCompressor类的具体用法?Java BrotliStreamCompressor怎么用?Java BrotliStreamCompressor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BrotliStreamCompressor类属于org.meteogroup.jbrotli包,在下文中一共展示了BrotliStreamCompressor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.meteogroup.jbrotli.BrotliStreamCompressor; //导入依赖的package包/类
@Setup
public void init() throws IOException {
BrotliLibraryLoader.loadBrotli();
brotliParameter = new Brotli.Parameter(Brotli.Mode.GENERIC, 5, Brotli.DEFAULT_LGWIN, Brotli.DEFAULT_LGBLOCK);
brotliCompressor = new BrotliCompressor();
brotliStreamCompressor = new BrotliStreamCompressor(brotliParameter);
out = new byte[24603];
outByteBuffer = ByteBuffer.allocateDirect(24603);
arrayOutputStream = new ByteArrayOutputStream(24603);
cpHtmlData = loadCanterburyCorpusHtmlFile();
cpHtmlDataByteBuffer = ByteBuffer.allocateDirect(cpHtmlData.length);
cpHtmlDataByteBuffer.put(cpHtmlData);
}
示例2: brotliCompress
import org.meteogroup.jbrotli.BrotliStreamCompressor; //导入依赖的package包/类
private byte[] brotliCompress(byte[] bytes) {
BrotliLibraryLoader.loadBrotli();
Brotli.Parameter param = new Brotli.Parameter()
.setMode(Brotli.Mode.TEXT)
.setQuality(11)
.setLgwin(10)
.setLgblock(0);
BrotliStreamCompressor streamCompressor = new BrotliStreamCompressor(param);
byte[] compressed = streamCompressor.compressArray(bytes, true);
streamCompressor.close();
return compressed;
}
示例3: compress
import org.meteogroup.jbrotli.BrotliStreamCompressor; //导入依赖的package包/类
public static byte[] compress(byte[] input) {
BrotliStreamCompressor compressor = new BrotliStreamCompressor();
return compressor.compressArray(input, true);
}
示例4: BrotliOutputStream
import org.meteogroup.jbrotli.BrotliStreamCompressor; //导入依赖的package包/类
public BrotliOutputStream(OutputStream outputStream, Brotli.Parameter parameter) {
this.outputStream = outputStream;
brotliStreamCompressor = new BrotliStreamCompressor(parameter);
}
示例5: assertCompressorHasSmallerBuffer
import org.meteogroup.jbrotli.BrotliStreamCompressor; //导入依赖的package包/类
private void assertCompressorHasSmallerBuffer(Brotli.Parameter parameter) {
try (BrotliStreamCompressor aCompressor = new BrotliStreamCompressor(parameter)) {
assertThat(aCompressor.getMaxInputBufferSize()).isLessThan(testBytes.length);
}
}
示例6: run
import org.meteogroup.jbrotli.BrotliStreamCompressor; //导入依赖的package包/类
private void run() throws Exception {
BrotliLibraryLoader.loadBrotli();
byte[] data = loadDemoData();
BrotliStreamCompressor brotliStreamCompressor = new BrotliStreamCompressor(Brotli.DEFAULT_PARAMETER);
byte[] compressedBuffer = brotliStreamCompressor.compressArray(data, true);
writeDemoDataCompressed(compressedBuffer);
}