从路径字符串创建FileWriter并将字符串值写入文本文件
import java.io.FileWriter; import java.io.IOException; import java.io.Writer;/*来 自 时 代 J a v a 公 众 号*/ public class FileWriterTest { public static void main(String[] args) throws IOException { Writer writer = null; try{ writer = new FileWriter("C:/output.txt"); writer.append("from nowjava.com"); }finally{ if(writer != null){ writer.close(); } } }/* from 时代Java公众号 - N o w J a v a . c o m*/ }