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
Write a program to calculate factorial in java?
When will you define a method as static?
What are classloaders?
What is the advantage of preparedstatement over statement?
Is singleton class thread safe?
What is the main use of java?
What is class and object in java?
What is the use of bufferedreader?
What do you understand by soft reference?
Can you access non static variable in static context?
What is t in generics in java?
What is rmi and steps involved in developing an rmi object?
What is difference between module and function?
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread
What is a static class in java?