问题描述
因此,我使用Apache POI将Excel文件解析为我的数据库。为此,我正在初始化 XSSFWorkbook
,如下所示:
So, I using Apache POI in order to parse an Excel file to my Database. For this I am initializing an XSSFWorkbook
as follows:
XSSFWorkbook workbook = new XSSFWorkbook(fIP);
然后我继续我的方法。 workbook.close()
不可用作以后关闭工作簿的方法。关于如何在任务完成后让垃圾收集进入工作簿的任何想法?
Then I proceed with my method. workbook.close()
is not available as a method to close the workbook afterwards. Any ideas of how can I let garbage collection take the workbook after the task is finished?
推荐答案
我有这个问题,它没什么意义。
最后我跟踪问题,我的IDE(netbeans)正在拿起早期版本的POI库(v3.8),它没有关闭方法。
因此,请检查您的类路径,并查找不同版本的POI库的重复导入。
I had this issue, and it was making little sense.In the end I tracked the issue down to my IDE (netbeans) was picking up an earlier version of the POI libraries (v3.8) which didn't have the "close" method.So check your class path and look for duplicate imports of different versions of the POI libraries.
这篇关于资源泄漏:使用Apache.POI XSSFWorkbook时,工作簿永远不会被关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!