java将System.out.println的输出导出到文件中
直接看代码
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 }