aspose file tools*
The moose likes Java in General and the fly likes How to Remove System.out.println() in my Application Code 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 Remove System.out.println() in my Application Code" Watch "How to Remove System.out.println() in my Application Code" New topic
Author

How to Remove System.out.println() in my Application Code

vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Hi ,

I have to remove System.out.println()'s in my total application.Is there any tool to remove all the System.out.println()'s...

I am using Jdeveloper tool.

Thanks In Advance,
Vipul Kumar.


Thanks
Vipul Kumar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41798
    
  62
Doesn't the editor have global search & replace?


Ping & DNS - my free Android networking tools app
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Hi Ulf Dittmer,

Thanks For your Reply.I haven't checked global search.I am using Microsoft visual source safe as confiuration management. I cannot global search and replace as i have to checkout each file and then remove System.out.println()'s..Is there any alternative to find System.out.println()'s in the application code...

Thanks In Advance,
Vipul Kumar.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41798
    
  62
How do you expect to remove something from the source code without changing the source code?
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Actually I don't mean that.

Doesn't the editor have global search & replace?


Your suggestion is good one. I can global search and replace the code if iam not using the configuration management.I cannot replace the code directly.I have to check in each file and then replace.It takes minimum 4-5 days to replace the code.Please suggest me another alternative...

Any way Thanks for your reply..

Thanks & Regards,
Vipul Kumar.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

vipul bondugula wrote:Please suggest me another alternative...

It is hard to suggest an alternate! you can write your own program to search and remove the System.out.println() in your source files.
but again you need to test the program in different test cases thoroughly! writing the tedious test case and testing may take 4 or 5 days
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10329
    
    8

It takes minimum 4-5 days to replace the code

I am not really sure understand what you mean here. I am using eclipse and I just searched for logger statements in my code. I got around 1327 hits in a few seconds.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Maneesh Godbole wrote: I am using eclipse and I just searched for logger statements in my code. I got around 1327 hits in a few seconds.

vipul dont have this facility in his work environment!

even in eclipse, searching System.out.println statement and replacing/removing is not that easy, for example
System.out.println("Logged Exception : "+e.getMaessage); you can highlight System.our.println, but what would happen to remaining strings! however you can replace System.out.println with // but still commented part remains in code!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41798
    
  62
Seetharaman Venkatasamy wrote:you can highlight System.our.println, but what would happen to remaining strings! however you can replace System.out.println with // but still commented part remains in code!

That's easy: Regexp search/replace - every decent editor and IDE has it.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11295
    
  16

Perl or AWK could do it in just a few lines.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Thanks For Your Replies.

In the global search iam having regular expression option.can anyone provide me search keyword to search System.out.println() statements. Actually i have provided "System.out.println(" but this does not work.Showing Regular Expression Error.

Thanks & Regards,
Vipul Kumar.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ulf Dittmer wrote:
That's easy: Regexp search/replace

Thanks
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

vipul bondugula wrote:Thanks For Your Replies.
can anyone provide me search keyword to search System.out.println() statements.


try this: System\.out\.print.*
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Thanks Seetharaman,

search keyword works fine.5779 System.out.println() statements out of 5260 files.

Now my team had to work a lot.check in files from server and remove..

Thank you once again..
Vipul Kumar.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19692
    
  20

As a lesson for next time, you should probably use a logging framework (e.g. Log4J, SLF4J, etc) instead of using System.out. That way you can increase the logging level (to debug for instance) when testing, and decrease it again (to info / warning) when deploying to production.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Remove System.out.println() in my Application Code