Apache Commons Compress 1.9 發布

jopen 10年前發布 | 6K 次閱讀 Apache Commons Compress

Apache Commons Compress 1.9 發布,此版本現已提供下載,在沒有 GZIP 的情況下支持原始壓縮流;修復了 7z 和 tar 包相關的 bug;改進了對 Java 庫 XZ 的檢測。

更新內容如下:

新特性
o Added support for DEFLATE streams without any gzip framing.
  Issue: COMPRESS-263.
  Thanks to Matthias Stevens.

Bugs 修復 o When reading 7z files unknown file properties and properties of type   kDummy are now ignored.   Issue: COMPRESS-287. o Expanding 7z archives using LZMA compression could cause an   EOFException.   Issue: COMPRESS-286.  o Long-Name and -link or PAX-header entries in TAR archives always had   the current time as last modfication time, creating archives that   are different at the byte level each time an archive was built.   Issue: COMPRESS-289.   Thanks to Bob Robertson.

改進 o Checking for XZ for Java may be expensive.  The result will now be   cached outside of an OSGi environment.  You can use the new   XZUtils#setCacheXZAvailability to overrride this default behavior.   Issue: COMPRESS-285.</pre>

Commons Compress 用以實現將文件壓縮或解壓成 tar、zip、bzip2 等格式。

下面代碼將文件壓縮成zip格式:

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

</div>

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);
}


來自:http://www.oschina.net/news/56031/apache-commons-compress-1-9-released

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!