java 文件续写
程序员文章站
2023-12-31 20:59:10
public class FileWriterDemo { public static void main(String[] args) { FileWriter fw = null; try { // 传递true,代表不覆盖已有文件,追加 fw = new FileWriter("demo.tx ......
public class filewriterdemo { public static void main(string[] args) { filewriter fw = null; try { // 传递true,代表不覆盖已有文件,追加 fw = new filewriter("demo.txt", true); fw.write("abcde\n"); } catch (ioexception e) { system.out.println(e.tostring()); } finally { try { if (fw != null) fw.close(); } catch (ioexception e) { e.printstacktrace(); } } } }