用Java的POI工具向excel追加数据时报错Exception in thread “main” java.io.FileNotFoundException: C:\Users\report\HK\HK Reboot Analysis (Nov-2023).xls (The requested operation cannot be performed on a file with a user-mapped section open)
报错如下
代码如下
解决
原因在于如上的代码频繁地通过新建和关闭 FileInputStream FileOutputStream来达到将链表数据一个一个写入到excel表格之中,大大消耗了内存降低了效率,使得线程紊乱报错;
解决办法是优化算法将FileInputStream FileOutputStream新建和关闭次数大大降低,如下