Using apache poi - Zip Bomb detected

后端 未结 3 569
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 07:06

When I am trying to write data to excel sheet using apache poi which contains more than 64000 records, where SXSSF is used and I am getting the below error,

3条回答
  •  我在风中等你
    2021-02-06 07:22

    You can avoid zip bomb issues reading from an InputStream instead of reading from a File like this

    File fp = new File(excelFile);
    FileInputStream fpis = new FileInputStream(fp);
    try {
        wb = WorkbookFactory.create(fpis);
    } finally {
        fpis.close();
    }
    

    But be aware that the documentation at WorkbookFactory.create(java.io.InputStream) says that "loading from an InputStream requires more memory than loading from a File"

提交回复
热议问题