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


Please Help Members By Posting Answers For Below Questions

What is unicode datatype?

533


What is singleton class in java and how can we make a class singleton?

579


What are facelets templates?

606


What are the types of collections in java?

545


Tell me the Importent classes in net package?

1586






What is the properties class?

565


Can we convert integer to string in java?

600


What is the primary benefit of encapsulation?

562


How do you sort data in java?

528


What are kinds of processors?

574


Can we have any other return type than void for main method?

542


What is compareto?

546


What is the r character?

590


What is a finally block? Is there a case when finally will not execute?

553


What does I ++ mean?

613