集册 Java实例教程 使用多个catch语句捕获多个异常

使用多个catch语句捕获多个异常

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

877
使用多个catch语句捕获多个异常

import java.io.FileInputStream;

import java.io.IOException;


public class Main {//from n  o  w  j  a  v  a . c o m

  public static void main(String[] args) {

    try {

      Class<?> stringClass = Class.forName("java.lang.String");

      FileInputStream in = new FileInputStream("myFile.log"); // Can throw IOException

      in.read();

    } catch (IOException e) {

      System.out.println("There was an IOException " + e);

    } 
展开阅读全文