您的位置:首页 > 其它

System.out. 输出到指定文件中

2016-07-11 00:00 323 查看
用下面的方法,就可以输出到指定文件中了

String strJSON = "这是一段字符串,这段字符串将会打印到指定文件中。";

//日志输出到指定文件中

PrintStream out;

try {

out = new PrintStream("C://Users//whr-pc//Desktop//classpath//img//Systemout.txt");

System.setOut(out);

System.out.println(strJSON);

} catch (FileNotFoundException e) {

e.printStackTrace();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: