We have a huge (old legacy java) code-base, where many files (around 5k) have System.out.println's. We are planning to remove them for cleanup/performance reasons. How can we write a script that will replace them without introducing any issues in the code? The script cannot blindly delete them as following case can be an issue:
if ()
some.code...
else
System.out.println(...);
DB.close();
I'm thinking of replacing them with ';'. That will take care of above case. Do you see any other issues? Any other suggestions?
Extending Oscar's concept you can do even better IMHO:
In this case, if you are not in debug mode or any other the default system out is replaced internally with devNull implementation, else it works as expected. This way you do not have to find and replace anything in your code.
Personally I would use
{}
instead, but I think it works just the same.