How can we redirect a Java program console output to multiple files?

后端 未结 5 413
忘掉有多难
忘掉有多难 2020-11-28 20:36

How can we redirect the eclipse console output to a file? I can:

  1. Run Configuration->Commons->Select a file.
  2. Use
5条回答
  •  情深已故
    2020-11-28 20:56

    We can do this by setting out variable of System class in the following way

    System.setOut(new PrintStream(new FileOutputStream("Path to output file"))). Also You need to close or flush 'out'(System.out.close() or System.out.flush()) variable so that you don't end up missing some output.

    Source : http://xmodulo.com/how-to-save-console-output-to-file-in-eclipse.html

提交回复
热议问题