http://www.verejava.com/?id=16994663236510
package com.io;
import java.io.*;
public class TestWriter
{
public static void main(String[] args)
{
Writer writer=null;
try
{
writer=new FileWriter(new File("res/writer_test.txt"));
//向文件中写入数据
String content="good morning";
writer.write(content);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
writer.close();//关闭输出流
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}