有点重定向使用的味道
import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; public class PrintStreamTest { public static void main(String[] args) { try { var fos = new FileOutputStream("test.txt"); var ps = new PrintStream(fos); { ps.println("普通字符串"); ps.println(new PrintStreamTest()); } } catch (FileNotFoundException e) { e.printStackTrace(); } } }
output:
原文地址:https://www.cnblogs.com/lianghong881018/p/11302456.html
时间: 2024-10-17 16:21:42