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 are the important features of Java 10 release?
What is files manifesting?
How are java objects passed to a method and what are native methods?
Distinguish between a predicate and a function?
Explain about sets?
What do you mean by order of precedence and associativity?
Why put method is idempotent?
Why is the main method declared static?
What is the argument in java?
how its run?
What are encapsulation, inheritance and polymorphism?
Java Compiler is stored in JDK, JRE or JVM?
What is a “stateless” protocol ?
Why are there no global variables in java?
What is a numeric literal?