wood burning stoves 2.0*
The moose likes Java in General and the fly likes How to avoid System.out.println() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to avoid System.out.println() " Watch "How to avoid System.out.println() " New topic
Author

How to avoid System.out.println()

Girish K Gupta
Greenhorn

Joined: Mar 14, 2007
Posts: 19

Hi All

I have a Java class file which has some System.out.prinltn() calls.
I want these SOPs should not be printed when I run the class (I am not supposed to modify the source .java file).

Please help me out.

PS: I don't know if this problem was discussed before on the forum, I tried searching but i didn't get any relevant thread.

Thanks!!


Girish K Gupta
SCJP 1.5 - 87%, SCWCD 1.5 - 92%
India
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 690
    
    1
Not modify the source?
Can you call/start the program in question from another program? If so, in the calling program you can change the value of System.out (setOut()) to be a NOP method before calling the program you can't modify.
Girish K Gupta
Greenhorn

Joined: Mar 14, 2007
Posts: 19

Thanks Norm, I will try your suggestion.
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
That's a weakness in the Java code, and obviously should be changed there.

Barring that, it depends on how you invoke the java application.

In most environments there are mechanisms for redirecting stdout and stderr to different places. (nowhere being one possibility)


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to avoid System.out.println()