public class BufferedWirter_ {public static void main(String[] args) throws IOException {String filepath = "e:\\ABC.txt";//创建BufferedWrite对象BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filepath,true));//BufferedWriter 并没有提供追加append true的方式,因此可以在FileWriter中加入trueString str = "I love write progress!";bufferedWriter.write(str+"\n");bufferedWriter.write(str+"签名人:XXX\n");bufferedWriter.write(str+"睡梦人");//另一个换行格式bufferedWriter.newLine();bufferedWriter.write("这是新的一行~");System.out.println("文字已经打印到文件中~");//说明:关闭外层流即可,传入的 new FileWriter(filePath),会在底层关闭bufferedWriter.close();}
}