java导入io错误_java.io.IOException:无法读取zip条目源

FileInputStream file = new FileInputStream("/file/path/report.xlsx");

XSSFWorkbook wb = new XSSFWorkbook(file); --!ERROR LINE!--

我在第二行收到错误.我查看了不同的在线资源,例如:

Exception in thread "main" java.io.IOException: Failed to read zip entry source

at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:106)

at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:342)

at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)

at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:285)

at test.test.main(test.java:48)

Caused by: java.io.IOException: Zip bomb detected! The file would exceed the max. ratio of compressed file size to the size of the expanded data. This may indicate that the file is used to inflate memory usage and thus could pose a security risk. You can adjust this limit via ZipSecureFile.setMinInflateRatio() if you need to work with files which exceed this limit. Counter: 1483367, cis.counter: 14796, ratio: 0.009974605070761314Limits: MIN_INFLATE_RATIO: 0.01

at org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.advance(ZipSecureFile.java:257)

at org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.read(ZipSecureFile.java:214)

at java.io.FilterInputStream.read(Unknown Source)

at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource$FakeZipEntry.(ZipInputStreamZipEntrySource.java:132)

at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.(ZipInputStreamZipEntrySource.java:56)

at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:99)

... 4 more

我添加了ZipSecureFile.setMinInflateRatio(0.009);

FileInputStream file = new FileInputStream("/file/path/report.xlsx");

ZipSecureFile.setMinInflateRatio(0.009);

XSSFWorkbook wb = new XSSFWorkbook(file);

它运行良好一段时间,然后它开始抛出相同的错误

任何帮助或指导表示赞赏.

解决方法:

添加以下行为我做了伎俩.

ZipSecureFile.setMinInflateRatio(-1.0d);

代码如下:

FileInputStream file = new FileInputStream("/file/path/report.xlsx");

ZipSecureFile.setMinInflateRatio(-1.0d);

XSSFWorkbook wb = new XSSFWorkbook(file);

标签:java,excel,apache-poi

来源: https://codeday.me/bug/20190622/1263907.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值