Java examples for Object Oriented Design:Exception
Handling Checked Exceptions
import java.io.FileInputStream; import java.io.FileNotFoundException; public class Main { public static void main(String[] args) { openFile("C:/test.txt"); }/*from w ww.ja v a 2 s .c o m*/ public static void openFile(String name) { try { FileInputStream f = new FileInputStream(name); } catch (FileNotFoundException e) { System.out.println("File not found."); } } }