Java System.setErr(PrintStream err)
Syntax
System.setErr(PrintStream err) has the following syntax.
public static void setErr(PrintStream err)
Example
In the following code shows how to use System.setErr(PrintStream err) method.
/*w w w.j ava 2 s . c o m*/
import java.io.FileOutputStream;
import java.io.PrintStream;
public class Main {
public static void main(String[] args) throws Exception {
FileOutputStream f = new FileOutputStream("file.txt");
System.setErr(new PrintStream(f));
System.err.println("This will get redirected to file from java2s.com");
}
}