I want to remove/comment all the occurrences of System.out.println from my java code.
This System.out.println may be inside if ,
You can make all System.out.println in your application not to print anything in console. Create a class like:
import java.io.PrintStream;
public class MyStream extends PrintStream {
private static final MyStream INSTANCE = new MyStream();
public static void init() {
System.setOut(INSTANCE);
}
private MyStream() {
super(System.out);
}
@Override
public void println(Object x) {
return;
}
@Override
public void println(String x) {
return;
}
}
Use it as:
public class Test {
public static void main(String... args) {
MyStream.init();
System.out.println("This line will not print");
}
}
The will not be printed anymore.