风故故,也依依

Stand still in the wind.

导航

用FileWriter将内容写入文本


import java.io.*;

public class FileWriterTest
{
public static void main(String[] args)
{
   FileWriterTest t = new FileWriterTest();
   t.WriteMyFile();
}

void WriteMyFile()
{
   try
   {
    FileWriter fw = new FileWriter("mydata.txt");
    PrintWriter out =new PrintWriter(fw);
    out.print("Hello,World!");
    out.close();
    fw.close();
   }
   catch(IOException e)
   {
    System.out.println("OH,got an IOException error!");
    e.printStackTrace();
   }
}
}

posted on 2007-05-28 00:28  jadmin  阅读(214)  评论(0编辑  收藏  举报