PrintStream 字节打印流
PrintWriter 字符打印流
@Test public void test9() throws Exception { FileOutputStream fos = new FileOutputStream("C:\Users\Mi\Documents\io\printStream.txt"); //重定向打印流。自动刷新(写入换行符或" "时flush) PrintStream ps = new PrintStream(fos, true); System.setOut(ps); for (int i = 0; i <= 255 ; i++) { //打印 System.out.print((char)i); if (i % 50 == 0){ System.out.println(); } } ps.close(); }