• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to avoid System.out.println()  RSS feed

 
Girish K Gupta
Greenhorn
Posts: 19
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Norm Radder
Rancher
Posts: 1733
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Norm, I will try your suggestion.
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!