Checked Exception In Java
Chapter:
Exception Handling
Last Updated:
19-04-2016 13:36:02 UTC
Program:
/* ............... START ............... */
import java.io.*;
public class JavaCheckedException {
public static void main(String[] args) throws IOException {
FileReader file = new FileReader("C:\\CheckException\\file.txt");
BufferedReader fileInput = new BufferedReader(file);
for (int counter = 0; counter < 10; counter++)
System.out.println(fileInput.readLine());
fileInput.close();
}
}
/* ............... END ............... */
Output
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code -
unreported exception java.io.FileNotFoundException; must be caught or declared to be
thrown at Main.main(Main.java:5)
Notes:
-
Checked exceptions are exceptions that are checked at compile time.
Tags
Checked Exception, Java