zoukankan      html  css  js  c++  java
  • 抓取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);
                }
    
                }
    
            
        }
    
        
    }

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

  • 相关阅读:
    mac 终端常见指令
    git常见指令
    iOS8的autolayout和size class
    UIWindow详解
    操作系统Unix、Windows、Mac OS、Linux的故事
    iOS引用当前显示的UIAlertView
    Unexpected CFBundleExecutable Key
    《CODE》讲了什么?
    exit和return的区别
    php 登录注册api接口代码
  • 原文地址:https://www.cnblogs.com/penghong2014/p/4530160.html
Copyright © 2011-2022 走看看