How could Java classes direct program messages to the
system console, but error messages, say to a file?
Answer Posted / munna
import java.io.*;
class Err
{
public static void main(String[] args) throws Exception
{
PrintStream ps=new PrintStream(new
FileOutputStream("output.txt"));
System.setErr(ps);
System.setOut(ps);
System.out.println("fdffdfdffffff........");
}
}
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
What is r in java?
How to access arraylist elements in java?
How do you define a parameter?
Which api is provided by java for operations on set of objects?
What kind of variables can a class consist?
What is the difference between the paint() and repaint() methods?
How do you remove an element from an arraylist in java?
Where are variables stored?
Can you explain the final method modifier?
Can we call virtual funciton in a constructor ?
What are the differences between graph and tree?
Give example to differentiate between call by value and call by reference.
What do you understand by the term polymorphism?
What is the exact difference in between unicast and multicast object? Where we will use?
What are the differences between string, stringbuffer and stringbuilder?