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 difference between module and function?
Define a package.
Can we override private methods?
What is a linkedhashmap java?
For class CFoo { }; what default methods will the compiler generate for you>?
Explain some best practices you would apply while using collection in java?
Is there a jre for java 11?
Can I extend singleton class in java?
What are operators and its types?
How many bytes is a url?
Why parsing is done?
Can we override private constructor in java?
What does compareto () do in java?
Why java is secure? Explain.
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.