System.out.println将内容输出到文件保存


try

   {
       PrintStream out = new PrintStream(fileName);
                 System.setOut(out);
   }
   catch(FileNotFoundException e)
   {
       e.printStackTrace();

   }


设置后System.out.println()将会把打印的内容直接输出到文件fileName中去。

猜你喜欢

转载自blog.csdn.net/u011806486/article/details/69665238