I have been using try-with-resources a lot. I use it for database resource types or File stuff all the time to close the resource.
Now, I am using POI for large Excel files, and I am just noticing that I should call workbook.dispose(). Will try-with-resources call the dispose() method? Everything I looked up only covers close().
I am not convinced that the duplicate is the same question. My question specifically asks if Dispose is handled by try-with-resource. None of the other questions mention Dispose.
closeon passed inAutoCloseable. In fact you can only useAutoCloseableobjects with try-with-resoures. POI objects implementAutoCloseable, but theircloseanddisposemethods are different. See SXSSFWorkbookclose: "Closes the underlying XSSFWorkbook and OPCPackage on which this Workbook is based, if any."dispose: "Dispose of temporary files backing this workbook on disk. Calling this method will render the workbook unusable."