Java 将控制台输出打印 输出到本地文件

版权声明:Boomlee https://blog.csdn.net/BoomLee/article/details/82691857

1.将控制台打印的信息输出到本地文件

File f=new File("D:\\out.txt");
        f.createNewFile();
        FileOutputStream fileOutputStream = new FileOutputStream(f);
        PrintStream printStream = new PrintStream(fileOutputStream);
        System.setOut(printStream);

猜你喜欢

转载自blog.csdn.net/BoomLee/article/details/82691857