码迷,mamicode.com
首页 > 编程语言 > 详细

java将System.out.println的输出导出到文件中

时间:2014-11-21 20:21:50      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   java   

直接看代码
bubuko.com,布布扣
1 public static void saveStreamToFile(String savePath,String input){
2       try {
3             //savePath like c:/log.txt
4             System.setOut(new PrintStream(new FileOutputStream(savePath)));
5             System.out.println(input);
6       } catch (FileNotFoundException e) {
7             e.printStackTrace();
8      }
9 }
View Code

 

java将System.out.println的输出导出到文件中

标签:style   blog   http   io   ar   color   os   sp   java   

原文地址:http://www.cnblogs.com/tommy-huang/p/4113590.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!