在主程序前加入以下代码:
fos = new FileOutputStream("f://text.txt");
BufferedOutputStream bos = new BufferedOutputStream(fos, 1024);
PrintStream ps = new PrintStream(bos, true);
System.setOut(ps);
注意:
不能在最后关闭ps,否则其他线程就不能输出到文件了。
在主程序前加入以下代码:
fos = new FileOutputStream("f://text.txt");
BufferedOutputStream bos = new BufferedOutputStream(fos, 1024);
PrintStream ps = new PrintStream(bos, true);
System.setOut(ps);
注意:
不能在最后关闭ps,否则其他线程就不能输出到文件了。