zoukankan      html  css  js  c++  java
  • Java 读取注册表信息

    查阅了好多资料都木有找到这个问题的答案,因为在registry类中没有访问注册表的key值,而只是通过key值来寻找value值。而做项目时需要获取key值。贴上代码仅供参考,(*^__^*) ……

     public String getStr(String string) {

    //string为查询语句,像reg query HKEY_CURRENT_USER/software

      String[] aStrings=null;//存储表信息

      String s="";   if(string!=null){    try {     String line;     Process ps  = Runtime.getRuntime().exec(string);//执行查询语句   

      InputStreamReader isr = new InputStreamReader(ps.getInputStream());     

      BufferedReader ir = new BufferedReader(isr);     

     while ((line = ir.readLine()) != null) {              

         aStrings=line.split(" ");      

                          s+=line;       }    } catch (IOException e) {     e.printStackTrace();    }   }    return s;  }

     public List<String> getPath(String pString) throws UnsupportedEncodingException{//3*i+4是key值,3*i+12是value值

      String[] strings=null;   strings=pString.split(" ");   Map<String, String>aa=new HashMap<>(); 

      List<String> alList=new ArrayList<>();      int a=strings.length;   for(int i=0;i<=(a-1-12)/3;i++){   

    alList.add(strings[3*i+4]);   aa.put(strings[3*i+4], strings[3*i+12]);   }  

     return alList;  } 

  • 相关阅读:
    asp.net 通过js调用webService注意
    身份证号码验证 类
    char值码对应大全
    C# 让textbox 只能输入数字的方法
    table嵌套循环数据
    拆分字符串
    angular的路由配置
    js对象数组(JSON) 根据某个共同字段 分组
    当前时间的后七天
    ajax提交时“加载中”提示的处理方法
  • 原文地址:https://www.cnblogs.com/findTurlyLove/p/5011014.html
Copyright © 2011-2022 走看看