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 are the important features of Java 10 release?

750


What is files manifesting?

1963


How are java objects passed to a method and what are native methods?

828


Distinguish between a predicate and a function?

773


Explain about sets?

765


What do you mean by order of precedence and associativity?

742


Why put method is idempotent?

655


Why is the main method declared static?

852


What is the argument in java?

695


how its run?

808


What are encapsulation, inheritance and polymorphism?

730


Java Compiler is stored in JDK, JRE or JVM?

1245


What is a “stateless” protocol ?

754


Why are there no global variables in java?

794


What is a numeric literal?

750