Try catch exceptions

I got this:publicvoid fileIO(){

try{

File file =new File("aNewFile.txt");

System.out.println(file.exists());

}catch (IOException ioe){

System.out.println("IOException");

}

}

which tells me : exception java.io.IOException is never thrown in body of correspondingtry statement

, if I change the catch to}catch (Exception ioe){

, the error goes away.

My question is why is it giving the error and why is it not giving the error after changing the catch line ?

[1028 byte] By [gtommoa] at [2007-11-27 11:03:33]
# 1

Read the API!!!!!!!!!

new File(String) may through a NullPointerException

and

file.exists() may through a SecurityException

Neither of those are based on an IOException, hence the error message when you use IOException.

All exceptions are based (somewhere down the line) on Exception, hence no error when you use Exception.

masijade.a at 2007-7-29 12:50:29 > top of Java-index,Java Essentials,New To Java...