java 壓縮文件異常:class java.io.IOException Request to write '8192' bytes exceeds size in header of '159423' bytes for entry 'image.tgz'


問題背景

使用 apache compress 組件在對一個文件夾執行 gzip 壓縮的時候報如下錯誤:

class java.io.IOException Request to write '8192' bytes exceeds size in header of '159423' bytes for entry 'image.tgz'

過程與結論

經排查發現,調用壓縮方法時,指定的輸出路徑處於需要被壓縮的目錄內:

  • 需要被壓縮的目錄:./dir
  • 壓縮文件輸出路徑:./dir/image.tgz

解決方案

將壓縮文件輸出路徑改為 ./image.tgz 后問題解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM