2.3.7异常的干扰

2.3.7异常的干扰_第1张图片
Paste_Image.png
import java.io.*;

public class MyReadFile {
    public static void main(String[] args){
        try {
            File f = new File("D:/test2.txt");
            
            FileInputStream fis = new FileInputStream(f);
            
            System.out.println(fis.read());
        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
        }
    }
}

java.io.FileNotFoundException: D:\test2.txt (系统找不到指定的文件。)
java.io.FileNotFoundException: D:\test2.txt (系统找不到指定的文件。)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.(FileInputStream.java:138)
    at MyReadFile.main(MyReadFile.java:8)
2.3.7异常的干扰_第2张图片
Paste_Image.png
2.3.7异常的干扰_第3张图片
Paste_Image.png
2.3.7异常的干扰_第4张图片
Paste_Image.png
2.3.7异常的干扰_第5张图片
Paste_Image.png
2.3.7异常的干扰_第6张图片
Paste_Image.png
2.3.7异常的干扰_第7张图片
Paste_Image.png
Paste_Image.png
import java.io.*;

public class MyReadFile {
    public static void main(String[] args){
        try {
            File f = new File("D:/test2.txt");
            
            FileInputStream fis = new FileInputStream(f);
            
            System.out.println(fis.read());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (IOException e) {
            // TODO: handle exception
        }catch (Exception e) {
            // TODO: handle exception
        }
    }
}

你可能感兴趣的:(2.3.7异常的干扰)