Below is the sample code snippet to create SXSSFWorkbook
:
try(SXSSFWorkbook wb = new SXSSFWorkbook()) {
//...
} finally {
wb.dispose(); //wb not accessible over here, so can't use try with resource
}
Here problem is that if I use try with resource then can't dispose()
SXSSFWorkbook
in finally, as variable wb
won't be accessible in finally block.
I wanted know that is disposing of workbook necessary to delete temporary files or since SXSSFWorkbook
is AutoCloseable
, try with resource will take care of it.