在java中不能追加excel文件内容获取堆转储错误

我正在使用apache-poi-3.16.我试图多次写入一个文件而不是一个镜头,但在intelliJ的想法中得到了heal dump error。请查找下面的代码以供参考,

public class SampleExcelGeneration { public static void main(String[] args) { SampleExcelGeneration excelGeneration = new SampleExcelGeneration(); excelGeneration.writeFile(); excelGeneration.writeFile(); excelGeneration.writeFile(); excelGeneration.writeFile(); excelGeneration.writeFile(); } private void writeFile () { try { final File file = new File("test.xlsx"); XSSFWorkbook wb; XSSFSheet sheet; if(file.exists()) { wb = new XSSFWorkbook(file.getAbsolutePath()); sheet = wb.getSheetAt(0); } else { wb = new XSSFWorkbook(); sheet = wb.createSheet("Results"); } int getLastRow = sheet.getPhysicalNumberOfRows(); int incrementLastRow = getLastRow+1; XSSFRow row = sheet.createRow(incrementLastRow); XSSFCell column1 = row.createCell(0); column1.setCellValue(1); XSSFCell column2 = row.createCell(1); column2.setCellValue(3); XSSFCell column3 = row.createCell(2); column3.setCellValue(380); XSSFCell column4 = row.createCell(3); column4.setCellValue("sample"); XSSFCell column5 = row.createCell(4); column5.setCellValue("value"); //write this workbook to an Outputstream. wb.write(new FileOutputStream(file.getAbsolutePath())); wb.close(); } catch (Exception e) { e.printStackTrace(); } } } 

在控制台中执行获取内容时,

 # # A fatal error has been detected by the Java Runtime Environment: # # SIGBUS (0xa) at pc=0x000000010acbde92, pid=77146, tid=0x0000000000001003 # # JRE version: Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.101-b13 mixed mode bsd-amd64 compressed oops) # Problematic frame: # C [libzip.dylib+0x2e92] newEntry+0x154 # # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again # # An error report file with more information is saved as: # /Users/dev/sample-excel/hs_err_pid77146.log Compiled method (nm) 1835 100 n 0 java.util.zip.ZipFile::getEntry (native) total in heap [0x000000010b7322d0,0x000000010b732630] = 864 relocation [0x000000010b7323f8,0x000000010b732438] = 64 main code [0x000000010b732440,0x000000010b732630] = 496 # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # Process finished with exit code 134 (interrupted by signal 6: SIGABRT) 

如果有任何其他exception意味着我可以得到一个提示,以解决问题,而是抛出一个堆转储错误,并破坏该文件。

原因可能是不正确的处理stream,但据我所知,我closures了所有的stream。

任何帮助或暗示将是可观的。