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

后端 未结 7 1890
失恋的感觉
失恋的感觉 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:44

    Update

    As mentioned here create a NullOutPut

    public final DevNull { 
        public final static PrintStream out = 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) {}
    
        } );
    }
    

    and replace System.out.print with DevNull.out.print

    and later switch to logging framework that will allow you to handle stuff easily


    Linked

    • How to remove System.out.println's from codebase

提交回复
热议问题