原来txt内容:
"我要添加内容"
import java.io.*; class Test { public static void main(String[] args) { FileWriter fw = null; BufferedWriter bw = null; String con = "tinyphp"; try { fw = new FileWriter("e://d/add.txt", true); //加true bw = new BufferedWriter(fw); bw.write(con); } catch (Exception e) { System.out.println(e); } finally { try { bw.close(); fw.close(); } catch (Exception e) { System.out.println(e); } } } }
运行后:文本为
"我要添加内容tinyphp"