当前页面: 开发资料首页 → J2EE 专题 → JAVA写txt文件的小问题
JAVA写txt文件的小问题
摘要: JAVA写txt文件的小问题
怎样从文本的最后一行开始写入,而不会把已有的内容抹掉?
try {
BufferedWriter out = new BufferedWriter(new FileWriter("c://filename.txt", true));//主要就是这个true
out.newLine();//如果不另起一行的话就注释掉
out.write("aString");
out.close();
} catch (IOException e) {
}
}
append 方法 追加file内容