public static String fetch_cpu_info() {
String result = null;
try {
String[ ] args = { "/system/bin/cat", "/proc/cpuinfo" };
result = run(args, "/system/bin/");
Log.i("result","result=" + result);
} catch (IOException ex) {
ex.printStackTrace();
}
return result;
}
public synchronized static String run ( String [] cmd,String workdirectory)
throws IOException {
String result = "";
try {
ProcessBuilder builder = new ProcessBuilder ( cmd );
//设置一个路径
if ( workdirectory != null )
builder.directory ( new File ( workdirectory ) ) ;
builder.redirectErrorStream (true) ;
Process process = builder.start ( ) ;
InputStream in = process.getInputStream ( ) ;
byte[] re = new byte[1024] ;
while (in.read(re) != -1){
result = result + new String (re) ;
}
in.close ( ) ;

} catch ( Exception ex ) {
ex.printStackTrace ( ) ;
}
return result ;
}

更多相关文章

  1. Android 7.0调用相机拍照并获取图片路径
  2. android加载文件的方式,路径的写法
  3. android的路径问题
  4. Android Studio 中如何更改SDK路径
  5. Android 获取assets的绝对路径
  6. Android 获取路径
  7. Android将获取到文件的uri转换为字符串的路径

随机推荐

  1. 阿里app法人认证备案流程
  2. 漫画头发怎么画好?漫画人物头发画法
  3. 领略 Laravel 和 Filament 后台的魔力
  4. Linux 自动化构建工具 make/Makefile
  5. 日系插画入门学什么?新手插画学习方法
  6. Android中native进程内存泄露的调试技巧
  7. 深入浅出 - Android系统移植与平台开发(六
  8. webservice二进制文件传输
  9. Android高手进阶教程(三)之----Android(
  10. Android多点触控开发原理