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();
            }
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/hongxiao2020/p/12674228.html
今日推荐