Java输出控制台错误消息到文件? [英] Java output console error message to file?
本文介绍了Java输出控制台错误消息到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的代码块输出控制台文本到一个文本文件在Java:
I have a simple piece of code that outputs console text to a text file in Java:
PrintStream out = new PrintStream(new FileOutputStream("test2_output.txt"));
System.setOut(out);
但是,我需要这个文本文件包含在控制台中生成的错误消息,
However I require this text file to contain the error messages that is produced in the console but they are not included.
如何执行此操作?
推荐答案
System.setErr(out);
结尾。
这篇关于Java输出控制台错误消息到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文