本文整理汇总了Java中org.apache.commons.compress.compressors.gzip.GzipParameters.setCompressionLevel方法的典型用法代码示例。如果您正苦于以下问题:Java GzipParameters.setCompressionLevel方法的具体用法?Java GzipParameters.setCompressionLevel怎么用?Java GzipParameters.setCompressionLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.compress.compressors.gzip.GzipParameters
的用法示例。
在下文中一共展示了GzipParameters.setCompressionLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openFastGzipParallelWriter
import org.apache.commons.compress.compressors.gzip.GzipParameters; //导入方法依赖的package包/类
/**
* Open a concurrent gzip compressed line writer (fastest compression)
* @param target target location
* @param limit the limit per split
* @param maxWriters the maximum number of writers
* @return parallel writer
*/
public static ParallelSplitWriter<String> openFastGzipParallelWriter(File target, final int limit, final int maxWriters) {
return new ParallelSplitWriter<String>(target, maxWriters) {
@Override
protected Writer<String> newWriter(File path) {
GzipParameters parameters = new GzipParameters();
parameters.setCompressionLevel(Deflater.BEST_SPEED);
parameters.setFilename(path.getName());
try {
return new LineWriter(new GzipCompressorOutputStream(new FileOutputStream(path.getAbsolutePath() + ".gz"), parameters), limit);
} catch (IOException e) {
throw new IOError(e);
}
}
};
}
示例2: compress
import org.apache.commons.compress.compressors.gzip.GzipParameters; //导入方法依赖的package包/类
public void compress(final File rootDir) throws IOException {
boolean deleteIncompleteTarGzFile = false;
final OutputStream fout = castStream(tarGzFile.createOutputStream());
try {
deleteIncompleteTarGzFile = true;
final GzipParameters gzipParameters = new GzipParameters();
gzipParameters.setCompressionLevel(Deflater.BEST_COMPRESSION);
final TarArchiveOutputStream out = new TarArchiveOutputStream(new GzipCompressorOutputStream(new BufferedOutputStream(fout), gzipParameters));
try {
writeTar(out, rootDir, rootDir);
} finally {
out.close();
}
deleteIncompleteTarGzFile = false;
} finally {
fout.close();
if (deleteIncompleteTarGzFile)
tarGzFile.delete();
}
}
示例3: main
import org.apache.commons.compress.compressors.gzip.GzipParameters; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
// Define where log messages go
ExampleHelpers.configureLogging();
// Print information about this program
printDocumentation();
// Initialize sites; only needed to link to Wikipedia pages in RDF
DumpProcessingController dumpProcessingController = new DumpProcessingController(
"wikidatawiki");
dumpProcessingController.setOfflineMode(ExampleHelpers.OFFLINE_MODE);
Sites sites = dumpProcessingController.getSitesInformation();
// Prepare a compressed output stream to write the data to
// (admittedly, this is slightly over-optimized for an example)
OutputStream bufferedFileOutputStream = new BufferedOutputStream(
ExampleHelpers
.openExampleFileOuputStream("wikidata-simple-statements.nt.gz"),
1024 * 1024 * 5);
GzipParameters gzipParameters = new GzipParameters();
gzipParameters.setCompressionLevel(7);
OutputStream compressorOutputStream = new GzipCompressorOutputStream(
bufferedFileOutputStream, gzipParameters);
OutputStream exportOutputStream = asynchronousOutputStream(compressorOutputStream);
// Create a serializer processor
RdfSerializer serializer = new RdfSerializer(RDFFormat.NTRIPLES,
exportOutputStream, sites,
PropertyRegister.getWikidataPropertyRegister());
// Serialize simple statements (and nothing else) for all items
serializer.setTasks(RdfSerializer.TASK_ITEMS
| RdfSerializer.TASK_SIMPLE_STATEMENTS);
// Run serialization
serializer.open();
ExampleHelpers.processEntitiesFromWikidataDump(serializer);
serializer.close();
}
示例4: makeCompressorOutputStream
import org.apache.commons.compress.compressors.gzip.GzipParameters; //导入方法依赖的package包/类
@Override
public CompressorOutputStream makeCompressorOutputStream(OutputStream stream)
throws IOException, CompressorException {
// set additional parameters for compressor stream
GzipParameters params = Gzip.getDefaultGzipParams(null);
params.setCompressionLevel(_compressionLevel);
return new GzipCompressorOutputStream(stream, params);
}
示例5: makeCompressorOutputStream
import org.apache.commons.compress.compressors.gzip.GzipParameters; //导入方法依赖的package包/类
@Override
protected CompressorOutputStream makeCompressorOutputStream(OutputStream stream,
CompressorOptions options) throws IOException {
// set additional parameters for compressor stream
GzipParameters params = getDefaultGzipParams(options.getName());
params.setCompressionLevel(_compressionLevel);
return new GzipCompressorOutputStream(stream, params);
}