System.setOut() - Setting Standard Console Output to


How could Java classes direct program messages to the system console, but error messages, say to a file?

✍: FYIcenter


The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both connected to the system console. But you can change them to files as shown in the this example:

Stream st = new Stream(new

2007-03-03, 7087👍, 0💬