Redirect standard error : Redirect « File Input Output « Java

Redirect standard error



public class Main {
  public static void main(String[] args) throws Exception {
    System.setErr(new PrintStream(new FileOutputStream("system_err.txt")));

    String nullString = null;
    nullString = nullString.toUpperCase();


Related examples in the same category

1.Redirect standard output
2.Redirecting Standard Output, and Error
3.Replace standard output and error with a print stream, output to both the console and to a file.
4.Standard Err and Output Windows
5.Redirect standard output to a file