0

我尝试将 PrintStream 打印到文本文件中,以便将一堆输出写入文件。

但是在创建文件之后,我试图切换回标准输出只是为了继续其他进程,但我不知道如何进行切换。好像我必须 setOut 到标准控制台,但我该怎么做呢?

下面是我用来输出到文本文件的代码。有任何想法吗?

PrintStream out = new PrintStream(fistr);
System.setOut(out);

谢谢。

4

1 回答 1

0

修改之前为什么不保存,这样就可以回去了?

PrintStream standard = System.out;
PrintStream out = new PrintStream(fistr);
System.setOut(out);
/*
 some other stuff
*/
System.setOut(standard);
于 2015-02-03T03:24:44.077 回答