10.4.10 PrintStream类

图10.15 运行结果
PrintStream 为其他输出流添加了功能,提供了print()、printf()和println()等打印方法,使它们能够方便地打印各种数据值表示形式。经常用到的System.out.println()语句中的out就是PrintStream类型的对象。
PrintStream常用构造方法:
public PrintStream(OutputStream out):构造方法参数类型为字节输出流,该流将作为输出目标。
【例10.17】(https://www.daowen.com)



图10.16 运行结果
运行后文件hello.txt中的内容如图10.16所示。