本文整理汇总了Java中org.tukaani.xz.XZ类的典型用法代码示例。如果您正苦于以下问题:Java XZ类的具体用法?Java XZ怎么用?Java XZ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XZ类属于org.tukaani.xz包,在下文中一共展示了XZ类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getInstance
import org.tukaani.xz.XZ; //导入依赖的package包/类
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);
}
开发者ID:dbrant,项目名称:zimdroid,代码行数:24,代码来源:Check.java
示例2: decodeStreamHeader
import org.tukaani.xz.XZ; //导入依赖的package包/类
public static StreamFlags decodeStreamHeader(byte[] buf)
throws IOException {
for (int i = 0; i < XZ.HEADER_MAGIC.length; ++i)
if (buf[i] != XZ.HEADER_MAGIC[i])
throw new XZFormatException();
if (!isCRC32Valid(buf, XZ.HEADER_MAGIC.length, 2,
XZ.HEADER_MAGIC.length + 2))
throw new CorruptedInputException("XZ Stream Header is corrupt");
try {
return decodeStreamFlags(buf, XZ.HEADER_MAGIC.length);
} catch (UnsupportedOptionsException e) {
throw new UnsupportedOptionsException(
"Unsupported options in XZ Stream Header");
}
}
开发者ID:dbrant,项目名称:zimdroid,代码行数:18,代码来源:DecoderUtil.java
示例3: getInstance
import org.tukaani.xz.XZ; //导入依赖的package包/类
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);
}
开发者ID:anadon,项目名称:JLS,代码行数:25,代码来源:Check.java
示例4: decodeStreamHeader
import org.tukaani.xz.XZ; //导入依赖的package包/类
public static StreamFlags decodeStreamHeader(byte[] buf) throws IOException {
for (int i = 0; i < XZ.HEADER_MAGIC.length; ++i)
if (buf[i] != XZ.HEADER_MAGIC[i])
throw new XZFormatException();
if (!isCRC32Valid(buf, XZ.HEADER_MAGIC.length, 2,
XZ.HEADER_MAGIC.length + 2))
throw new CorruptedInputException("XZ Stream Header is corrupt");
try {
return decodeStreamFlags(buf, XZ.HEADER_MAGIC.length);
} catch (UnsupportedOptionsException e) {
throw new UnsupportedOptionsException(
"Unsupported options in XZ Stream Header");
}
}
开发者ID:anadon,项目名称:JLS,代码行数:17,代码来源:DecoderUtil.java
示例5: decodeStreamFooter
import org.tukaani.xz.XZ; //导入依赖的package包/类
public static StreamFlags decodeStreamFooter(byte[] buf) throws IOException {
if (buf[10] != XZ.FOOTER_MAGIC[0] || buf[11] != XZ.FOOTER_MAGIC[1]) {
// NOTE: The exception could be XZFormatException too.
// It depends on the situation which one is better.
throw new CorruptedInputException("XZ Stream Footer is corrupt");
}
if (!isCRC32Valid(buf, 4, 6, 0))
throw new CorruptedInputException("XZ Stream Footer is corrupt");
StreamFlags streamFlags;
try {
streamFlags = decodeStreamFlags(buf, 8);
} catch (UnsupportedOptionsException e) {
throw new UnsupportedOptionsException(
"Unsupported options in XZ Stream Footer");
}
streamFlags.backwardSize = 0;
for (int i = 0; i < 4; ++i)
streamFlags.backwardSize |= (buf[i + 4] & 0xFF) << (i * 8);
streamFlags.backwardSize = (streamFlags.backwardSize + 1) * 4;
return streamFlags;
}
开发者ID:anadon,项目名称:JLS,代码行数:27,代码来源:DecoderUtil.java
示例6: decodeStreamFooter
import org.tukaani.xz.XZ; //导入依赖的package包/类
public static StreamFlags decodeStreamFooter(byte[] buf)
throws IOException {
if (buf[10] != XZ.FOOTER_MAGIC[0] || buf[11] != XZ.FOOTER_MAGIC[1]) {
// NOTE: The exception could be XZFormatException too.
// It depends on the situation which one is better.
throw new CorruptedInputException("XZ Stream Footer is corrupt");
}
if (!isCRC32Valid(buf, 4, 6, 0))
throw new CorruptedInputException("XZ Stream Footer is corrupt");
StreamFlags streamFlags;
try {
streamFlags = decodeStreamFlags(buf, 8);
} catch (UnsupportedOptionsException e) {
throw new UnsupportedOptionsException(
"Unsupported options in XZ Stream Footer");
}
streamFlags.backwardSize = 0;
for (int i = 0; i < 4; ++i)
streamFlags.backwardSize |= (buf[i + 4] & 0xFF) << (i * 8);
streamFlags.backwardSize = (streamFlags.backwardSize + 1) * 4;
return streamFlags;
}
开发者ID:dbrant,项目名称:zimdroid,代码行数:28,代码来源:DecoderUtil.java
示例7: XzStep
import org.tukaani.xz.XZ; //导入依赖的package包/类
/**
* 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);
}
开发者ID:saleehk,项目名称:buck-cutom,代码行数:17,代码来源:XzStep.java
示例8: testXzStep
import org.tukaani.xz.XZ; //导入依赖的package包/类
@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));
}
开发者ID:facebook,项目名称:buck,代码行数:32,代码来源:XzStepTest.java
示例9: testXzStep
import org.tukaani.xz.XZ; //导入依赖的package包/类
@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);
}
开发者ID:saleehk,项目名称:buck-cutom,代码行数:39,代码来源:XzStepTest.java
示例10: XzStep
import org.tukaani.xz.XZ; //导入依赖的package包/类
/**
* 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);
}
开发者ID:facebook,项目名称:buck,代码行数:21,代码来源:XzStep.java
注:本文中的org.tukaani.xz.XZ类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论