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

Answer Posted / biru3121

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 point at the
system console. This how the standard output could be re-
directed:

Stream st = new Stream(new FileOutputStream("output.txt"));
System.setErr(st);
System.setOut(st);

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why vector is used in java?

767


Does java runtime require a license?

775


What is canonical name in java?

833


How do you execute a thread in java?

717


What is n in java?

736


What is a functional interface?

754


What are the types of web technologies?

775


What is the program compilation process?

784


What is hotjava?

742


What is percentage in java?

764


What is difference between string and stringbuffer?

707


What is the difference between char and char *?

766


is it possible to instantiate the math class?

730


What is the use of volatile in java?

809


What is the dot operator?

764