欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

java IO异常处理

程序员文章站 2022-06-22 15:54:41
public class FileWriterDemo { public static void main(String[] args) { FileWriter fw = null; try { fw = new FileWriter("s:\\demo.txt"); fw.write("abcd ......
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();
            }
        }
    }
}