Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



How could Java classes direct program messages to the system console, but error messages, say to a..

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

How could Java classes direct program messages to the system console, but error messages, say to a..

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

Post New Answer

More Core Java Interview Questions

What is super keyword in java ?

1 Answers  


What are namespaces in java?

0 Answers  


Hi Friends.. can any one provide the real time example for methodoverloading and methodoverriding .........

2 Answers   Honeywell,


does java support default argument in Method?

1 Answers  


What is the collections api in java programming?

0 Answers  


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.

2 Answers  


Can u write constructor in abstract.If yes den when it will be invoked.

4 Answers   SunGard,


Describe the various concepts related to object oriented programming (oop).

0 Answers  


What are the parts of methodology?

0 Answers  


what is the constructor and how many types of constructors are used in java?

0 Answers  


What is meant by Java ?

2 Answers   CMC, Infosys,


What are class members by default?

0 Answers   Hexaware,


Categories