风故故,也依依

Stand still in the wind.

导航

用BufferedWriter和FileWriter实现文件读写

import java.io.*;

public class ToFile
{
public static void main(String[] args)
{
   try
   {
    String filename = "out.txt";
    BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
    bw.write("Hello,China!");
    bw.write("\n");
    bw.write("Hello,World!");
    bw.close();
   }
   catch(IOException e)
   {
    System.out.println("IOException");
    e.printStackTrace();
   }
}
}

posted on 2007-10-08 21:45  jadmin  阅读(320)  评论(0编辑  收藏  举报