How could Java classes direct program messages to the
system console, but error messages, say to a file?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / 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 |
What is super keyword in java ?
What are namespaces in java?
Hi Friends.. can any one provide the real time example for methodoverloading and methodoverriding .........
does java support default argument in Method?
What is the collections api in java programming?
We have two methods to create methods the threads. 1. Implementing runnable interface 2. Extending to thread class and overriding run method. Among these two which one is better and why? Please explain me in detail.
Can u write constructor in abstract.If yes den when it will be invoked.
Describe the various concepts related to object oriented programming (oop).
What are the parts of methodology?
what is the constructor and how many types of constructors are used in java?
What is meant by Java ?
What are class members by default?