美文网首页
2.3.7异常的干扰

2.3.7异常的干扰

作者: linhaoyou | 来源:发表于2017-07-12 15:01 被阅读0次
    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.<init>(FileInputStream.java:138)
        at MyReadFile.main(MyReadFile.java:8)
    
    Paste_Image.png Paste_Image.png Paste_Image.png Paste_Image.png Paste_Image.png 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异常的干扰

          本文链接:https://www.haomeiwen.com/subject/fjavhxtx.html