抓取Log的脚本

package studyjava;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class getlog {
    public static void main(String[] args) throws Exception
    {
        File file=new File("E:\logs33");
        if(!file.exists())
            file.mkdir();
        get("adb pull storage/sdcard0/logs ",file,"mtklogs");
        System.out.println("mtklogs已导完成");
        get("adb pull data/anr ",file,"anrlog");
        System.out.println("anr已导完成");
    }
    public static void get(String cmd,File file,String logname) throws Exception
    {
        Process p1=Runtime.getRuntime().exec(cmd+file);
        InputStream in1=p1.getInputStream();
        InputStreamReader ir1=new InputStreamReader(in1);
        BufferedReader br=new BufferedReader(ir1);
        String str1;

        while((str1=br.readLine())!=null)
        {   
            Pattern pattern=Pattern.compile(".+files pulled.+");
            Matcher m=pattern.matcher(str1);
            if(m.find())
            {  
                break;
                }
            else
            {   
                Thread.sleep(1000);
            }

            }

        
    }

    
}

可是为什么正则表达式匹配那不执行打印语句呢

原文地址:https://www.cnblogs.com/penghong2014/p/4530160.html