• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java XZ类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ASMData类代码示例发布时间:2022-05-23
下一篇:
Java ConnectedComponent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap