In the following piece of code :
import java.io.*;
import java.io.FileReader;
public class ExceptionPropagationDemo {
public static void main(String[] args){
ExceptionPropagationDemo testObject =new ExceptionPropagationDemo();
testObject.throwException1();
}
public void throwCheckedException(){
try{ //try - catch error block
BufferedReader br;
br = new BufferedReader(new FileReader("/Project1/src/employee.txt"));
} catch(FileNotFoundException e){
System.out.println("An IO exception happened and has been handled");
}
finally {
System.out.println("This block always executes.");
}
}
public void throwException2() {
throwCheckedException();
}
public void throwException1(){
throwException2();
}
}
I'm trying to catch a checked exception and handle it. In my case it would be FileNotFoundException, but I don't know for what reason it never runs the catch block which I'm trying to print a message or any other functionality, but it seems it jumps over.Thank you