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 do you understand by weak reference?
Is static a keyword in java?
Name few java.lang classes introduced with java 8 ?
What is the old name of java?
What is static keyword in java?
What is member in java?
What is a finally block? Is there a case when finally will not execute?
What is the difference between compiler and jvm?
How many boolean functions are there?
What is difference between checked and unchecked exception in java?
Implement a stack with push (), pop() and min() in O(1) time.
What does @param args mean in java?
How does remove work in java?
What are constructors in java?
What is the point of java?