直接看代码
public static void saveStreamToFile(String savePath,String input){
try {
//savePath like c:/log.txt
System.setOut(new PrintStream(new FileOutputStream(savePath)));
System.out.println(input);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}