KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The Java I/O classes java.io.Reader , java.io.Writer , java.io.InputStream , java.io.OutpuStream and their various subclasses all have a close() method that can throw an IOException . Is there any consensus on the proper way to handle such exceptions? I have often seen recommendations to just silently ignore them, but that feels wrong, and at least in case of resources opened for writing, a problem while closing the file might mean that unflushed data could not be written/sent. On the other hand, when reading resources, I'm totally unclear on why close() might throw and what to do about it. So is there any standard recommendation? A related question is Does close ever throw an IOException? , but that is more about which implementations really do throw, not about how to handle the exceptions.
Tags (comma-separated)
Save Edits
Cancel