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
What is the different types of functions?
How do you create a bulleted list?
What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?
Explain the features of interfaces in java?
What is locale?
Class c implements interface I containing method m1 and m2 declarations. Class c has provided implementation for method m2. Can I create an object of class c?
How do you create an array in java?
What is the difference between a loader and a compiler?
What if I write static public void instead of public static void in java?
What do you mean by object?
What are nested classes in java?
What is the program compilation process?
What is the scope or life time of instance variables?
How do you find the independent variable?
How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?