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


Java GzipParameters.setCompressionLevel方法代码示例

本文整理汇总了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);
            }
        }
    };
}
 
开发者ID:marcusklang,项目名称:wikiforia,代码行数:23,代码来源:LineWriter.java

示例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();
	}
}
 
开发者ID:cloudstore,项目名称:cloudstore,代码行数:22,代码来源:TarGzFile.java

示例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();
	}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit-Examples,代码行数:40,代码来源:RdfSerializationExample.java

示例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);
}
 
开发者ID:turbolocust,项目名称:GZipper,代码行数:9,代码来源:Tarball.java

示例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);
}
 
开发者ID:turbolocust,项目名称:GZipper,代码行数:9,代码来源:Gzip.java


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