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

If a class is declared without any access modifiers, where can the class be accessed?

601


How is it possible for two string objects with identical values not to be equal under the == operator?

530


What is variable explain?

530


What are the six ways to use this keyword?

617


What is local variable and instance variable?

613






Why do we use bufferedreader?

542


Explain about complier design(phases)

632


What is time complexity algorithm?

550


Write code to implement bubble sort in java?

560


What is the byte order of byte buffer?

571


What is an immutable object? How do you create one in java?

604


what is the messsage u r going to get from an objectoriented programing?

1617


What is null statement?

539


What do you mean by inner class in java?

572


Who found java?

557