集册 Java实例教程 处理检查的异常

处理检查的异常

欢马劈雪     最近更新时间:2020-01-02 10:19:05

576
处理检查的异常

import java.io.FileInputStream;//from nowjava.com - 时  代  Java

import java.io.FileNotFoundException;


public class Main {

  public static void main(String[] args) {

    openFile("C:/test.txt");

  }


  public static void openFile(String name) {

    try {

      FileInputStream f = new FileInputStream(name);

    } catch (FileNotFoundException e) {

      System.out.println("File not found.");

    }

  }

}