Java examples for Object Oriented Design:Exception
Use boolean variable to track if exception happended
import java.io.FileInputStream; import java.io.FileNotFoundException; public class Main { public static boolean openFile(String name) {//w ww . ja v a2 s.c o m boolean fileOpened = false; try { FileInputStream f = new FileInputStream(name); fileOpened = true; } catch (FileNotFoundException e) { } return fileOpened; } }