java IO异常处理

public class FileWriterDemo {
    public static void main(String[] args) {
        FileWriter fw = null;
        try {
            fw = new FileWriter("s:\\demo.txt");
            fw.write("abcde");
        } catch (IOException e) {
            System.out.println(e.toString());
        } finally {
            try {
                if (fw != null)
                    fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

 

posted @ 2020-04-10 16:18  hongxiao2020  阅读(266)  评论(0)    收藏  举报