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


Java GzipParameters类代码示例

本文整理汇总了Java中org.apache.commons.compress.compressors.gzip.GzipParameters的典型用法代码示例。如果您正苦于以下问题:Java GzipParameters类的具体用法?Java GzipParameters怎么用?Java GzipParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GzipParameters类属于org.apache.commons.compress.compressors.gzip包,在下文中一共展示了GzipParameters类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getDefaultGzipParams

import org.apache.commons.compress.compressors.gzip.GzipParameters; //导入依赖的package包/类
/**
 * Returns {@link GzipParameters} with the operating system, modification
 * time (which is the current time in milliseconds) and the specified
 * filename without the directory path already set.
 *
 * @param filename the name of the file without directory path.
 * @return the default {@link GzipParameters}.
 */
public static GzipParameters getDefaultGzipParams(String filename) {
    GzipParameters params = new GzipParameters();
    Settings settings = Settings.getInstance();
    int osValue = settings.getOs().getOsInfo().getValue();
    params.setOperatingSystem(osValue);
    params.setModificationTime(System.currentTimeMillis());
    if (filename != null && !filename.contains(File.separator)) {
        params.setFilename(filename);
    }
    return params;
}
 
开发者ID:turbolocust,项目名称:GZipper,代码行数:20,代码来源:Gzip.java

示例6: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。