...
Code Block | ||
---|---|---|
| ||
public class Operation { static void doOperation(String some_file) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(some_file)); try { // Do operations } finally { closeIgnoringException(reader); // Other clean-up code } } private static void closeIgnoringException(BufferredReader s) { if (s != null) { try { s.close(); } catch (IOException ie) { // Ignore exception if close fails } } } public static void main(String[] args) throws IOException { doOperation("somepath"); } } |
...