源代码如下:
package com.Sixping.Ncre;
import java.io.*;
public class ExceptionCatch {
public static void main(String[] args) {
try {
FileNotFoundException fis = new FileNotFoundException("text");
System.out.println("content of text is:");
} catch (FileNotFoundException e) {
System.out.println(e);
System.out.println("massage:" + e.getMessage());
e.printStackTrace(System.out);
} catch (IOException e) {
System.out.println(e);
}
}
}
运行显示如下:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Unreachable catch block for FileNotFoundException. This exception is never thrown from the try statement body
Unreachable catch block for IOException. This exception is never thrown from the try statement body
at com.Sixping.Ncre.ExceptionCatch.main(ExceptionCatch.java:10)
求大神指教。