System.out.println removal/comment from multiple java source files

后端 未结 7 1824
失恋的感觉
失恋的感觉 2021-01-13 11:08

I want to remove/comment all the occurrences of System.out.println from my java code. This System.out.println may be inside if ,

7条回答
  •  迷失自我
    2021-01-13 11:53

    As Jigar Joshi said, using find & replace approach might help you a lot, especially if you don't interfere the code apart from System.out.println.

    I would propose a different solution if editing/changing the source code is not MUST for you. You can disable the System.out stream in your driver program, then nothing will be printed by these statements. You only need to set it like this:

    System.setOut(new PrintStream(new OutputStream() {
        public void write(int b) {
            // No operation.
        }
        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) {}
    }));
    

提交回复
热议问题