I've created a class like below and am wondering why I am unable to simply catch and rethrow an exception:
public class TestClass implements Runnable {
@Override
public void run() {
try{
FileInputStream inStream = new FileInputStream("");
}catch(Exception e){
throw e;
}
}
}
Eclipse is showing a compilation error: "Unhandled exception type FileNotFoundException" and suggests the following fix, which for some reason compiles fine:
@Override
public void run() {
try{
FileInputStream istream = new FileInputStream("");
}catch(Exception e){
try {
throw e;
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
What is going on here?