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
Extending Oscar's concept you can do even better IMHO:
if(!DEBUG) {
System.setOut(
new PrintStream(new OutputStream() {
public void close() {}
public void flush() {}
public void write(byte[] b) {}
public void write(byte[] b, int off, int len) {}
public void write(int b) {}
} );
}
}
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.