本文整理汇总了Java中org.tukaani.xz.XZ.CHECK_CRC32属性的典型用法代码示例。如果您正苦于以下问题:Java XZ.CHECK_CRC32属性的具体用法?Java XZ.CHECK_CRC32怎么用?Java XZ.CHECK_CRC32使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.tukaani.xz.XZ
的用法示例。
在下文中一共展示了XZ.CHECK_CRC32属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
public static Check getInstance(int checkType)
throws UnsupportedOptionsException {
switch (checkType) {
case XZ.CHECK_NONE:
return new None();
case XZ.CHECK_CRC32:
return new CRC32();
case XZ.CHECK_CRC64:
return new CRC64();
case XZ.CHECK_SHA256:
try {
return new SHA256();
} catch (java.security.NoSuchAlgorithmException e) {}
break;
}
throw new UnsupportedOptionsException(
"Unsupported Check ID " + checkType);
}
示例2: getInstance
public static Check getInstance(int checkType)
throws UnsupportedOptionsException {
switch (checkType) {
case XZ.CHECK_NONE:
return new None();
case XZ.CHECK_CRC32:
return new CRC32();
case XZ.CHECK_CRC64:
return new CRC64();
case XZ.CHECK_SHA256:
try {
return new SHA256();
} catch (java.security.NoSuchAlgorithmException e) {
}
break;
}
throw new UnsupportedOptionsException("Unsupported Check ID "
+ checkType);
}
示例3: XzStep
/**
* Creates an XzStep to compress a file with XZ compression level 4.
*
* <p> The destination file will be {@code sourceFile} with the added {@code .xz} extension.
* <p> Decompression will require 5MiB of RAM.
*
* @param sourceFile file to compress
*/
public XzStep(Path sourceFile) {
this(
sourceFile,
Paths.get(sourceFile + ".xz"),
/* compressionLevel */ 4,
/* keep */ false,
XZ.CHECK_CRC32);
}
示例4: testXzStep
@Test
public void testXzStep() throws InterruptedException, IOException {
final Path sourceFile =
TestDataHelper.getTestDataScenario(this, "xz_with_rm_and_check").resolve("xzstep.data");
final File destinationFile = tmp.newFile("xzstep.data.xz");
XzStep step =
new XzStep(
TestProjectFilesystems.createProjectFilesystem(tmp.getRoot().toPath()),
sourceFile,
destinationFile.toPath(),
/* compressionLevel -- for faster testing */ 1,
/* keep */ true,
XZ.CHECK_CRC32);
ExecutionContext context = TestExecutionContext.newInstance();
assertEquals(0, step.execute(context).getExitCode());
ByteSource original = PathByteSource.asByteSource(sourceFile);
ByteSource decompressed =
new ByteSource() {
@Override
public InputStream openStream() throws IOException {
return new XZInputStream(new FileInputStream(destinationFile));
}
};
assertTrue(
"Decompressed file must be identical to original.", original.contentEquals(decompressed));
}
示例5: testXzStep
@Test
public void testXzStep() throws IOException {
final File sourceFile = new File(
TestDataHelper.getTestDataScenario(this, "xz_with_rm_and_check"),
"xzstep.data");
final File destinationFile = tmp.newFile("xzstep.data.xz");
XzStep step = new XzStep(
sourceFile.toPath(),
destinationFile.toPath(),
/* compressionLevel -- for faster testing */ 1,
/* keep */ false,
XZ.CHECK_CRC32);
ProjectFilesystem fs = EasyMock.createMock(ProjectFilesystem.class);
EasyMock.expect(fs.deleteFileAtPath(sourceFile.toPath())).andReturn(true);
EasyMock.replay(fs);
ExecutionContext context = TestExecutionContext.newBuilder()
.setProjectFilesystem(fs)
.build();
assertEquals(0, step.execute(context));
ByteSource original = Files.asByteSource(sourceFile);
ByteSource decompressed = new ByteSource() {
@Override
public InputStream openStream() throws IOException {
return new XZInputStream(new FileInputStream(destinationFile));
}
};
assertTrue(
"Decompressed file must be identical to original.",
original.contentEquals(decompressed));
EasyMock.verify(fs);
}
示例6: XzStep
/**
* Creates an XzStep to compress a file with XZ at a user supplied compression level .
*
* <p>The destination file will be {@code sourceFile} with the added {@code .xz} extension.
*
* <p>Decompression will require up to 64MiB of RAM.
*
* @param sourceFile file to compress
* @param compressionLevel value from 0 to 9. Higher values result in better compression, but also
* need more time to compress and will need more RAM to decompress.
*/
public XzStep(ProjectFilesystem filesystem, Path sourceFile, int compressionLevel) {
this(
filesystem,
sourceFile,
Paths.get(sourceFile + ".xz"),
compressionLevel,
/* keep */ false,
XZ.CHECK_CRC32);
}