Trouble with try-catch-finally

Hi Geert,

The flush() method throws IOException. If that happens, you won’t get to the close(), which is why you’re still getting an issue. So you can nest a try/catch inside your finally, or just use a try-with-resources (for far cleaner code).

Ann

2 Likes