本文整理汇总了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);
}
}
};
}
示例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: 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;
}
示例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);
}