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中加入true String 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(); } }