<!--字符打印流-->
public class CharDemo { public static void main(String[] args) throws Exception { // 创建字符打印流 PrintWriter p = new PrintWriter(new FileWriter(new File("src/打印流_输出流/text.txt"), true)); p.print("黄伟强"); p.println(); p.print(345); p.close(); } }
<!--字节打印流-->
public class ByteDemo { public static void main(String[] args) throws Exception { // 创建字节打印流 PrintStream p = new PrintStream(new FileOutputStream(new File("src/打印流_输出流/text.txt"), true)); p.print("黄"); p.println(); p.print(123); p.close(); } }
时间: 2024-08-08 01:15:48