java.io.IOException: request to write '8024' bytes exceeds size in header of '0' bytes for entry 'TBND_0.xls'
at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.write(TarArchiveOutputStream.java:382)
at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:78)
at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:57)
at com.xQuant.product.xrisk.transfer.utils.GZIPUtil.pack(CommunicateItfFtpCompressUtils.java:273)
at com.xQuant.product.xrisk.transfer.utils.Test.main(Test.java:32)
java.io.IOException: request to write '8024' bytes exceeds size in header of '0' bytes for entry 'TBND_1.xls'
at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.write(TarArchiveOutputStream.java:382)
at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:78)
at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:57)
at com.xQuant.product.xrisk.transfer.utils.GZIPUtil.pack(CommunicateItfFtpCompressUtils.java:273)
at com.xQuant.product.xrisk.transfer.utils.Test.main(Test.java:32)
錯誤原因:TarArchiveEntry 沒有初始化大小
解決辦法:
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(file.getName());
tarArchiveEntry.setSize(file.length()); // 設置一個文件大小即可