IOException

package CoreJavaPractice;

import java.io.*;
public class Practice_2 {

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

        }

    }
}

 

posted @ 2019-09-06 17:36  蚂蚁雅黑1010  阅读(411)  评论(0编辑  收藏  举报