I read that the catch
block in try-with-resources is optional.
I\'ve tried creating a Connection
object in a try-with-resources block, with no subsequ
You could just be throwing the exception up (or catching it in another try-catch block):
private static void test() throws IOException {
try(InputStream is = new FileInputStream("test.txt")) {
while(is.read() > -1) {
}
} finally {
// Will get executed, even if exception occurs
System.out.println("Finished");
}
}