你好,游客 登录 注册 搜索
背景:
阅读新闻

Apache Commons Compress 1.7 发布

[日期:2014-01-21] 来源:oschina.net  作者:Linux [字体:大 中 小]

Apache Commons Compress 1.7 发布,此版本添加了 Snappy 只读支持和传统的 Unix.Z 压缩,同时还有一些 tar 和 7z 包的 bug 修复。源代码和二进制下载。

主要更新内容如下:
新特性:

o Read-Only support for Snappy compression.
Issue: COMPRESS-147. Thanks to BELUGA BEHR.
o Read-Only support for .Z compressed files.
Issue: COMPRESS-243. Thanks to Damjan Jovanovic.
o ZipFile and ZipArchiveInputStream now support reading entries
compressed using the SHRINKING method. Thanks to Damjan Jovanovic.
o GzipCompressorOutputStream now supports setting the compression
level and the header metadata (filename, comment, modification time,
operating system and extra flags)
Issue: COMPRESS-250. Thanks to Emmanuel Bourg.
o ZipFile and ZipArchiveInputStream now support reading entries
compressed using the IMPLODE method.
Issue: COMPRESS-115. Thanks to Emmanuel Bourg.
o ZipFile and the 7z file classes now implement Closeable and can be
used in try-with-resources constructs.

bug 修复:
o SevenZOutputFile#closeArchiveEntry throws an exception when using
LZMA2 compression on Java8. Issue: COMPRESS-241.
o 7z reading of big 64bit values could be wrong.
Issue: COMPRESS-244. Thanks to Nico Kruber.
o TarArchiveInputStream could fail to read an archive completely.
Issue: COMPRESS-245.
o The time-setters in X5455_ExtendedTimestamp now set the
corresponding flags explicitly - i.e. they set the bit if the valus
is not-null and reset it otherwise. This may cause
incompatibilities if you use setFlags to unset a bit and later set
the time to a non-null value - the flag will now be set.
Issue: COMPRESS-242.
o SevenZOutputFile would create invalid archives if more than six
empty files or directories were included. Issue: COMPRESS-252.

更多内容请看:http://commons.apache.org/compress/

Commons Compress 用以实现将文件压缩或解压成 tar、zip、bzip2 等格式。

下面代码将文件压缩成zip格式:

ArArchiveEntry entry = new ArArchiveEntry(name, size);
arOutput.putArchiveEntry(entry);
arOutput.write(contentOfEntry);
arOutput.closeArchiveEntry();

Zip文件的解压缩:

ArArchiveEntry entry = (ArArchiveEntry) arInput.getNextEntry();
byte[] content = new byte[entry.getSize()];
LOOP UNTIL entry.getSize() HAS BEEN READ {
    arInput.read(content, offset, content.length - offset);
}

linux
相关资讯       Commons Compress 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款