Apache Commons Compress 1.17 已发布,和平时一样,该版本包含 bug 修复和新功能的引入。引入了一个新的接口 InputStreamStatistics,可用于监视由大多数压缩器和一些归档输入流(archiving input streams)实现的解压进度。
下载地址:http://commons.apache.org/proper/commons-compress/download_compress.cgi
其它一些新特性
- Added a unit test that is supposed to fail if we break the OSGi manifest entries again.
- Add a new SkipShieldingInputStream class that can be used with streams that throw an IOException when skip is invoked.
- New constructors have been added to SevenZFile that accept char[]s rather than byte[]s in order to avoid a common error of using the wrong encoding when creating the byte[]. This change may break source compatibility for client code that uses one of the constructors expecting a password and passes in null as password. We recommend to change the code to use a constructor without password argument.
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);
} 继续阅读与本文标签相同的文章
-
AIoT入门:用虚拟设备体验物联网平台设备上云&设备数据存储
2026-05-18栏目: 教程
-
基于宜搭的“企业报销流程”实践案例
2026-05-18栏目: 教程
-
计算的旋律—阿里云视觉语言的探索
2026-05-18栏目: 教程
-
数据库实例性能调优利器-Performance Insights最佳实践
2026-05-18栏目: 教程
-
[集合]Collection源码解析(1)
2026-05-18栏目: 教程
