File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Overloading  System.out.println(); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Overloading  System.out.println();" Watch "Overloading  System.out.println();" New topic
Author

Overloading System.out.println();

Prasath Manohar
Greenhorn

Joined: Mar 21, 2006
Posts: 2
Is it possible to overload an object,can I overload System.out ?
Ashutosh Limaye
Ranch Hand

Joined: Oct 24, 2005
Posts: 58
Check out the System class in docs....see what an out object is...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60985
    
  65

Prasath Manoha, please take more care in chosing which forum in which to post your questions. This forum is for JDBC questions.

I've moved this post to Java in General (beginner).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Originally posted by Prasath Manohar:
Is it possible to overload an object,can I overload System.out ?


Overloading an object? How do you that?

I see some people assigning System.out object to some referene and call println method on that reference.

for example:

java.io.PrintStream ps = System.out;
ps.println("Hello world");
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
Originally posted by Prasath Manohar:
Is it possible to overload an object,can I overload System.out ?


I think you are expecting to use different stream to print rather than the console.

If thats is the case,

You can use System.setOut(PrintStream);

Example
For printing all the System.out.println() to a file.

System.setOut(new PrintStream(new FileOutputStream("console.log")));

Of course, this will no more print to the console for all System.out.println().
[ March 22, 2006: Message edited by: Dilip Kumar Jain ]

Manesh
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Note that the above has nothing to do with overloading at all.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
Don't get me started about those stupid light bulbs.
 
subject: Overloading System.out.println();