是用perl ,ant, 或find grep?

解决方案 »

  1.   

    这个有意思。一般都用 replaceWith 单个文件中批量删除。
      

  2.   

    eclipse ,选中项目 ,ctrl+h ,选  file search, 输入 System.out.print(?)  表达式,勾选正则表达式选项, 按 replace 。有这个功能,但是我没用过,你可以试试。
      

  3.   

    一般用replace 把 system.out.println语句 全部替换成 空
      

  4.   

    嘿嘿,工程开始的时候,做好debug方法,现在就不用这么头疼了。
      

  5.   

    用excel会很简单……
    用excelVBA更简单
      

  6.   


    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.FileWriter;public class DeleteString { /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    FileReader fr = new FileReader("c:\\111.java");
    BufferedReader br = new BufferedReader(fr);
    FileWriter fw = new FileWriter("c:\\22.java");
    while (br.ready()) {
    String str = br.readLine() + "\r\n";
    if (str.indexOf("System.out.print") < 0) {
    fw.write(str);
    }
    }
    fw.flush();
    fr.close();
    fw.close();
    }}
      

  7.   

    定义一个空函数 MyDebug.println
    然后用批量替换吧system.out.println换成MyDebug.println
      

  8.   

    一般遇到这种情况我都死查找替换~!
    ps:<ctrl + h > 出现查找对话框 在对话框的下面有三个按钮“replace”,“search”,“cancel”
    点“replace”按钮将system.out.println 替换长“”
      

  9.   

    直接用dreamweaver 把system.out.println替换为//system.out.println
      

  10.   

    办法很多,替换就成,Eclipse之类的ide都有这功能,至少word也能。还是在开始做项目的时候用debug框架吧,log4j之类的东西。这样就方便多了。下次想再让他们显示也方便。
      

  11.   

    我们或许可以换种角度去思考,把 System.out 的输出流重定向到 log4j 或者其他日志中去:log4j.xml 配置(放到 src 下,即 classpath 下):<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5p %t [%c{1}] %m%n" />
        </layout>
      </appender>
      
      <logger name="SystemOut">
        <level value="DEBUG" />
        <appender-ref ref="CONSOLE" /> 
      </logger>
      
      <root>
        <priority value="INFO" />
      </root>
    </log4j:configuration>
    测试类:public class SystemOutLog {
        
        static {
            Log4jPrintStream.redirectSystemOut();
        }    public static void main(String[] args) {
            for(int i = 0; i < 10; i++) {
                System.out.print("abc");
                System.out.print(i);
                System.out.print((char)(i + 0x21));
            }
        }
    }Log4jPrintStream 的实现:
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.PrintStream;
    import java.util.Locale;import org.apache.log4j.Logger;public class Log4jPrintStream extends PrintStream {    private Logger log = Logger.getLogger("SystemOut");    private static PrintStream instance = new Log4jPrintStream(System.out);    private Log4jPrintStream(OutputStream out) {
            super(out);
        }    public static void redirectSystemOut() {
            System.setOut(instance);
        }    public PrintStream append(char c) {
            // Ignore
            return this;
        }    public PrintStream append(CharSequence csq, int start, int end) {
            // Ignore
            return this;
        }    public PrintStream append(CharSequence csq) {
            // Ignore
            return this;
        }    public boolean checkError() {
            // Ignore
            return false;
        }    protected void clearError() {
            // Ignore
        }    public void close() {
            // Ignore
        }    public void flush() {
            // Ignore
        }    public PrintStream format(Locale l, String format, Object... args) {
            // Ignore
            return this;
        }    public PrintStream format(String format, Object... args) {
            // Ignore
            return this;
        }    public void print(boolean b) {
            println(b);
        }    public void print(char c) {
            println(c);
        }    public void print(char[] s) {
            println(s);
        }    public void print(double d) {
            println(d);
        }    public void print(float f) {
            println(f);
        }    public void print(int i) {
            println(i);
        }    public void print(long l) {
            println(l);
        }    public void print(Object obj) {
            println(obj);
        }    public void print(String s) {
            println(s);
        }    public PrintStream printf(Locale l, String format, Object... args) {
            // Ignore
            return this;
        }    public PrintStream printf(String format, Object... args) {
            // Ignore
            return this;
        }    public void println() {
            // Ignore
        }    public void println(boolean x) {
            log.debug(Boolean.valueOf(x));
        }    public void println(char x) {
            log.debug(Character.valueOf(x));
        }    public void println(char[] x) {
            log.debug(x == null ? null : new String(x));
        }    public void println(double x) {
            log.debug(Double.valueOf(x));
        }    public void println(float x) {
            log.debug(Float.valueOf(x));
        }    public void println(int x) {
            log.debug(Integer.valueOf(x));
        }    public void println(long x) {
            log.debug(x);
        }    public void println(Object x) {
            log.debug(x);
        }    public void println(String x) {
            log.debug(x);
        }    protected void setError() {
            // Ignore
        }    public void write(byte[] buf, int off, int len) {
            // Ignore
        }    public void write(int b) {
            // Ignore
        }    public void write(byte[] b) throws IOException {
            // Ignore
        }
    }把 System.out 的输出流重定向到 log4j 的 DEBUG 级别日志中去
      

  12.   

    为了提高效率,还能改成这样:    public void println(boolean x) {
            if(log.isDebugEnabled()) {
                log.debug(Boolean.valueOf(x));
            }        
        }    public void println(char x) {
            if(log.isDebugEnabled()) {
                log.debug(Character.valueOf(x));
            }
        }    public void println(char[] x) {
            if(log.isDebugEnabled()) {
                log.debug(x == null ? null : new String(x));
            }
        }    public void println(double x) {
            if(log.isDebugEnabled()) {
                log.debug(Double.valueOf(x));
            }
        }    public void println(float x) {
            if(log.isDebugEnabled()) {
                log.debug(Float.valueOf(x));
            }
        }    public void println(int x) {
            if(log.isDebugEnabled()) {
                log.debug(Integer.valueOf(x));
            }
        }    public void println(long x) {
            if(log.isDebugEnabled()) {
                log.debug(Long.valueOf(x));
            }
        }
      

  13.   

    用editplus或者ultraedit都可以批量替换所有文件里面的
      

  14.   

    我一般自己写个print工具集来调用,不直接写System.out.println,便于在需要时统一关掉它或重定向。
      

  15.   

    long time ago ..
    ...
      

  16.   

    建议 System.out.pr全部替换成//
      

  17.   

    每天回帖即可获得10分可用分!小技巧:教您如何更快获得可用分  
    这里发言,表示您接受了CSDN社区的用户行为准则。 
    请对您的言行负责,并遵守中华人民共和国有关法律法规,尊重网上道德。 
    转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。 
      

  18.   

    ctrl+h查询一下所有的,在替换一下。