Cleanup needs to occur
during normal and
exceptional
processing
Example: Close a file
FileReader reader = null; try { reader = new FileReader(name); ... } finally { if (reader != null) reader.close(); }
Exception example: UrlDump
Takes an URL, reads the web page line by line and prints it to stdout.
A custom UrlDumpException class is defined, with extra state identifying
the faulty URL string.