I am working as a trainee in Test Automation. I am working with creating Junit code with Eclipse and run using Eclipse. In that I am retriving the datas from excel sheet usi
It's always a good idea to close resources you use, BUT:
If you use resource A in resource B, it's sensible to close B instead of A if it has a method for it.
In your case, you use FileInputStream
in Workbook
, so you'd better to close Workbook
and rely on Workbok
that it will close FileInputStream
.
In this particular case, actually, Workbook
will close FileInputStream
at the end of the getWorkbook()
method but it's still a good idea to close Workbook
to be able to be garbage collected.