The class System has a variable that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This is how the standard output could be re-directed:
Stream st = new Stream(new FileOutputStream(”output.txt”)); System.setErr(st); System.setOut(st);