Handling Checked Exceptions - Java Object Oriented Design

Java examples for Object Oriented Design:Exception

Description

Handling Checked Exceptions

Demo Code

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.");
    }
  }
}

Related Tutorials