3 ms·
How does catching exceptions absolve us of the need to remember to close files?
by chc 16y ago
How does catching exceptions absolve us of the need to remember to close files?
- teilo 16y agoThis isn't about exceptions, though it is certainly part of the problem. Try, catch, finally blocks are commonly used to ensure that resources are released once they are no longer used. It not only forces you to remember to close the resources, it also forces you to think about what happens if something in your code breaks, and you have these open resources still in use. It's practically the entire reason that the "finally" block exists.