Consider the following code segment:
OutputStream os = new FileOutputStream("log.txt"); System.setErr(new PrintStream(os)); // SET SYSTEM.ERR System.err.println("Error");
Which one of the following statements is true regarding this code segment?.
d.
note that you can redirect the System.err programmatically using the setErr()
method.
System.err is of type PrintStream, and the System.setErr()
method takes a PrintStream as an argument.
Once the error stream is set, all writes to System.err will be redirected to it.
hence, this program will create log.txt with the text "error" in it.