本文整理汇总了Java中org.tukaani.xz.LZMA2Options类的典型用法代码示例。如果您正苦于以下问题:Java LZMA2Options类的具体用法?Java LZMA2Options怎么用?Java LZMA2Options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LZMA2Options类属于org.tukaani.xz包,在下文中一共展示了LZMA2Options类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateArtifactsXZ
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
private void updateArtifactsXZ(String artifactsXML) throws IOException
{
Path xzFile = Paths.get(outputDirectory.getAbsolutePath(), "repository", "artifacts.xml.xz"); //$NON-NLS-1$ //$NON-NLS-2$
try (FileOutputStream outfile = new FileOutputStream(xzFile.toFile()))
{
LZMA2Options options = new LZMA2Options();
options.setDictSize(LZMA2Options.DICT_SIZE_DEFAULT);
options.setLcLp(3, 0);
options.setPb(LZMA2Options.PB_MAX);
options.setMode(LZMA2Options.MODE_NORMAL);
options.setNiceLen(LZMA2Options.NICE_LEN_MAX);
options.setMatchFinder(LZMA2Options.MF_BT4);
options.setDepthLimit(512);
try (XZOutputStream outxz = new XZOutputStream(outfile, options))
{
outxz.write(artifactsXML.getBytes(StandardCharsets.UTF_8.name()));
}
}
}
开发者ID:buchen,项目名称:fix-info-plist-maven-plugin,代码行数:21,代码来源:FixInfoPlistMojo.java
示例2: write
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Override
public void write(byte[] b, int off, int len) throws IOException {
if (resetStateNeeded) {
resetStateNeeded = false;
xzOut = new XZOutputStream(out, new LZMA2Options(presetLevel));
blockOffset = 0;
}
while (len > 0) {
int chunk = (int) (blockOffset + len < blockSize ? len : blockSize - blockOffset);
xzOut.write(b, off, chunk);
off += chunk;
len -= chunk;
blockOffset += chunk;
if (blockOffset == blockSize) {
xzOut.endBlock();
blockOffset = 0;
}
}
}
开发者ID:yongtang,项目名称:hadoop-xz,代码行数:20,代码来源:XZCompressionOutputStream.java
示例3: XzStep
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
/**
* Create an {@link XzStep} to compress a file using XZ.
* @param sourceFile file to compress
* @param destinationFile where to store compressed data
* @param compressionLevel a value between 0-9, it impacts memory requirements for decompression
* @param keep by default, {@code xz} deletes the source file when compressing. This argument
* forces {@code xz} to keep it.
* @param check integrity check to use. Must be one of {@link XZ#CHECK_CRC32},
* {@link XZ#CHECK_CRC64}, {@link XZ#CHECK_SHA256}, {@link XZ#CHECK_NONE}
* (Note: XZ Embedded can only verify CRC32).
*/
@VisibleForTesting
XzStep(
Path sourceFile,
Path destinationFile,
int compressionLevel,
boolean keep,
int check) {
this.sourceFile = Preconditions.checkNotNull(sourceFile);
this.destinationFile = Preconditions.checkNotNull(destinationFile);
Preconditions.checkArgument(compressionLevel >= LZMA2Options.PRESET_MIN &&
compressionLevel <= LZMA2Options.PRESET_MAX, "compressionLevel out of bounds.");
this.compressionLevel = compressionLevel;
this.keep = keep;
this.check = check;
}
开发者ID:saleehk,项目名称:buck-cutom,代码行数:27,代码来源:XzStep.java
示例4: execute
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Override
public int execute(ExecutionContext context) {
try (
InputStream in = new BufferedInputStream(new FileInputStream(sourceFile.toFile()));
OutputStream out =
new BufferedOutputStream(new FileOutputStream(getDestinationFile().toFile()));
XZOutputStream xzOut = new XZOutputStream(out, new LZMA2Options(compressionLevel), check)
) {
ByteStreams.copy(in, xzOut);
xzOut.finish();
} catch (IOException e) {
e.printStackTrace(context.getStdErr());
return 1;
}
if (!keep && !context.getProjectFilesystem().deleteFileAtPath(sourceFile)) {
return 1;
}
return 0;
}
开发者ID:saleehk,项目名称:buck-cutom,代码行数:20,代码来源:XzStep.java
示例5: XzStep
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
/**
* Create an {@link XzStep} to compress a file using XZ.
*
* @param sourceFile file to compress
* @param destinationFile where to store compressed data
* @param compressionLevel a value between 0-9, it impacts memory requirements for decompression
* @param keep by default, {@code xz} deletes the source file when compressing. This argument
* forces {@code xz} to keep it.
* @param check integrity check to use. Must be one of {@link XZ#CHECK_CRC32}, {@link
* XZ#CHECK_CRC64}, {@link XZ#CHECK_SHA256}, {@link XZ#CHECK_NONE} (Note: XZ Embedded can only
* verify CRC32).
*/
@VisibleForTesting
XzStep(
ProjectFilesystem filesystem,
Path sourceFile,
Path destinationFile,
int compressionLevel,
boolean keep,
int check) {
this.filesystem = filesystem;
this.sourceFile = sourceFile;
this.destinationFile = destinationFile;
Preconditions.checkArgument(
compressionLevel >= LZMA2Options.PRESET_MIN && compressionLevel <= LZMA2Options.PRESET_MAX,
"compressionLevel out of bounds.");
this.compressionLevel = compressionLevel;
this.keep = keep;
this.check = check;
}
开发者ID:facebook,项目名称:buck,代码行数:31,代码来源:XzStep.java
示例6: execute
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Override
public StepExecutionResult execute(ExecutionContext context)
throws IOException, InterruptedException {
try (InputStream in = filesystem.newFileInputStream(sourceFile);
OutputStream out = filesystem.newFileOutputStream(destinationFile);
XZOutputStream xzOut = new XZOutputStream(out, new LZMA2Options(compressionLevel), check)) {
XzMemorySemaphore.acquireMemory(compressionLevel);
ByteStreams.copy(in, xzOut);
xzOut.finish();
if (!keep) {
filesystem.deleteFileAtPath(sourceFile);
}
} finally {
XzMemorySemaphore.releaseMemory(compressionLevel);
}
return StepExecutionResults.SUCCESS;
}
开发者ID:facebook,项目名称:buck,代码行数:18,代码来源:XzStep.java
示例7: newOutput
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Override
protected OutputService<TarDriverEntry> newOutput(
final FsModel model,
final FsOutputSocketSink sink,
final InputService<TarDriverEntry> input)
throws IOException {
final class Sink extends AbstractSink {
@Override
public OutputStream stream() throws IOException {
final OutputStream out = sink.stream();
try {
return new FixedXZOutputStream(
new FixedBufferedOutputStream(out, getBufferSize()),
new LZMA2Options(getPreset()));
} catch (final Throwable ex) {
try {
out.close();
} catch (final Throwable ex2) {
ex.addSuppressed(ex2);
}
throw ex;
}
}
} // Sink
return new MultiplexingOutputService<>(getPool(),
new TarOutputService(model, new Sink(), this));
}
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:28,代码来源:TarXZDriver.java
示例8: compressXZ
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
void compressXZ(ByteArrayOutputStream out) throws IOException {
LZMA2Options opts = new LZMA2Options();
// preset manage compression level at all, DictSize limit allow to rn test on low-memory devices
opts.setPreset(3);
opts.setDictSize(1 << 18);
XZOutputStream wrapperOS = new XZOutputStream(out, opts);
wrapperOS.write(data);
wrapperOS.close();
}
开发者ID:android-workloads,项目名称:JACWfA,代码行数:10,代码来源:XZ.java
示例9: openOutputStream
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
public static DataOutputStream openOutputStream(String filename) throws IOException {
FSUtil.makeParentDirectories(filename);
if (filename.endsWith(".gz")) {
return new DataOutputStream(new GZIPOutputStream(new FileOutputStream(filename)));
} else if (filename.endsWith(".bz") || filename.endsWith(".bz2")) {
return new DataOutputStream(new BZip2CompressorOutputStream(new FileOutputStream(filename)));
} else if(filename.endsWith(".xz")) {
return new DataOutputStream(new XZOutputStream(new FileOutputStream(filename), new LZMA2Options()));
} else {
return new DataOutputStream(new FileOutputStream(filename));
}
}
开发者ID:teanalab,项目名称:demidovii,代码行数:14,代码来源:StreamCreator.java
示例10: finish
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Override
public void finish() throws IOException {
if (resetStateNeeded) {
resetStateNeeded = false;
xzOut = new XZOutputStream(out, new LZMA2Options(presetLevel));
blockOffset = 0;
}
xzOut.finish();
resetStateNeeded = true;
}
开发者ID:yongtang,项目名称:hadoop-xz,代码行数:11,代码来源:XZCompressionOutputStream.java
示例11: flush
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Override
public void flush() throws IOException {
if (resetStateNeeded) {
resetStateNeeded = false;
xzOut = new XZOutputStream(out, new LZMA2Options(presetLevel));
blockOffset = 0;
}
xzOut.flush();
}
开发者ID:yongtang,项目名称:hadoop-xz,代码行数:10,代码来源:XZCompressionOutputStream.java
示例12: close
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Override
public void close() throws IOException {
if (resetStateNeeded) {
resetStateNeeded = false;
xzOut = new XZOutputStream(out, new LZMA2Options(presetLevel));
blockOffset = 0;
}
xzOut.flush();
xzOut.close();
resetStateNeeded = false;
}
开发者ID:yongtang,项目名称:hadoop-xz,代码行数:12,代码来源:XZCompressionOutputStream.java
示例13: benchmark
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Test
public void benchmark() throws IOException {
/*
Snappy compress: 0.156672s
Compressed to 10876881 bytes
Uncompresses to 12908620 bytes
Snappy decompress: 0.162463s
Deflate Fastest compress: 6.017877s
Compressed to 7770401 bytes
Uncompresses to 12908620 bytes
Deflate Fastest decompress: 4.260146s
Deflate Slowest compress: 7.06043s
Compressed to 7492001 bytes
Uncompresses to 12908620 bytes
Deflate Slowest decompress: 3.968221s
Deflate Normal compress: 5.201332s
Compressed to 7515522 bytes
Uncompresses to 12908620 bytes
Deflate Normal decompress: 4.056792s
*/
benchmark("None", x -> x, x -> x);
benchmark("None", x -> x, x -> x);
benchmark("Snappy", SnappyOutputStream::new, SnappyInputStream::new);
benchmark("GZip", GZIPOutputStream::new, GZIPInputStream::new);
benchmark("Deflate Fastest", os -> new DeflaterOutputStream(os, new Deflater(Deflater.BEST_SPEED)), InflaterInputStream::new);
benchmark("Deflate Normal", os -> new DeflaterOutputStream(os, new Deflater(Deflater.DEFAULT_COMPRESSION)), InflaterInputStream::new);
benchmark("Deflate Slowest", os -> new DeflaterOutputStream(os, new Deflater(Deflater.BEST_COMPRESSION)), InflaterInputStream::new);
benchmark("BZip2 Fastest", os -> new BZip2CompressorOutputStream(os, BZip2CompressorOutputStream.MIN_BLOCKSIZE), BZip2CompressorInputStream::new);
benchmark("BZip2 Slowest", os -> new BZip2CompressorOutputStream(os, BZip2CompressorOutputStream.MAX_BLOCKSIZE), BZip2CompressorInputStream::new);
benchmark("XZ Fastest", os -> new XZCompressorOutputStream(os, LZMA2Options.PRESET_MIN), XZCompressorInputStream::new);
benchmark("XZ Normal", os -> new XZCompressorOutputStream(os, LZMA2Options.PRESET_DEFAULT), XZCompressorInputStream::new);
benchmark("XZ Slowest", os -> new XZCompressorOutputStream(os, LZMA2Options.PRESET_MAX), XZCompressorInputStream::new);
}
开发者ID:batterseapower,项目名称:timeseries-compression,代码行数:37,代码来源:ConditionerParameterSearchTest.java
示例14: pack
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
/**
* Compress the zipFile.
*/
@Override
protected void pack() {
try (XZOutputStream zOut = new XZOutputStream(
Files.newOutputStream(zipFile.toPath()), new LZMA2Options())) {
zipResource(getSrcResource(), zOut);
} catch (IOException ioe) {
String msg = "Problem creating xz " + ioe.getMessage();
throw new BuildException(msg, ioe, getLocation());
}
}
开发者ID:apache,项目名称:ant,代码行数:14,代码来源:Xz.java
示例15: compress
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
public static byte[] compress(String log) throws IOException {
ByteArrayOutputStream xzOutput = new ByteArrayOutputStream();
XZOutputStream xzStream = new XZOutputStream(xzOutput,
new LZMA2Options(LZMA2Options.PRESET_MAX));
xzStream.write(log.getBytes());
xzStream.close();
return xzOutput.toByteArray();
}
开发者ID:IPEldorado,项目名称:RemoteResources,代码行数:9,代码来源:StringUtils.java
示例16: compressFile
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
private void compressFile(String inputName, String outputName) throws IOException {
try (InputStream input = new FileInputStream(inputName);
FileOutputStream fos = new FileOutputStream(outputName);
final OutputStream output = new XZOutputStream(fos, new LZMA2Options());
final ReadableByteChannel inputChannel = Channels.newChannel(input);
final WritableByteChannel outputChannel = Channels.newChannel(output)) {
fastChannelCopy(inputChannel, outputChannel);
} catch (IOException ignored) {
}
}
开发者ID:mediathekview,项目名称:MLib,代码行数:12,代码来源:WriteFilmlistJson.java
示例17: getPreset
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Override
public int getPreset() {
return LZMA2Options.PRESET_MIN;
}
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:5,代码来源:TestTarXZDriver.java
示例18: FixedXZOutputStream
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
FixedXZOutputStream(final FixedBufferedOutputStream out, final LZMA2Options options) throws IOException {
super(out, options);
this.out = out;
}
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:5,代码来源:TarXZDriver.java
示例19: XzStrategy
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
public XzStrategy() {
sizeRecorder = new DataSizeRecordStream();
xzOptions = new LZMA2Options();
}
开发者ID:takashi-ishio,项目名称:NCDSearch,代码行数:5,代码来源:XzStrategy.java
示例20: xzFastest
import org.tukaani.xz.LZMA2Options; //导入依赖的package包/类
@Benchmark
public int xzFastest() throws IOException {
return benchmark(os -> new XZCompressorOutputStream(os, LZMA2Options.PRESET_MIN), XZCompressorInputStream::new);
}
开发者ID:batterseapower,项目名称:timeseries-compression,代码行数:5,代码来源:JMHCompressorTest.java
注:本文中的org.tukaani.xz.LZMA2Options类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论