public static void main(String[] args) throws IOException {
String path = "d:\\test.txt";
FileWriter fw = new FileWriter(path, true); // true 表示在文件上续写
PrintWriter pw = new PrintWriter(fw);
String str = new String("hello");
pw.write(str);
pw.flush(); // 需要刷新缓冲区才能输出
fw.flush();
pw.close();
fw.close();
}