java將System.out.println的輸出導出到文件中

1 public static void saveStreamToFile(String savePath,String input){ 2 try { 3 //savePath like c:/log.txt4 System.setOut(new PrintStream(new FileOutputStream(savePath)));5 System.out.println(input);6 } catch (FileNotFoundException e) { 7 e.printStackTrace();8 }9 }View Code
作者:一菲聰天
來源鏈接:https://www.cnblogs.com/tommy-huang/p/4113590.html
未經允許不得轉載:>貴州網站建設公司 » java將System.out.println的輸出導出到文件中