Android Runtime.getRuntime().exec
2017-09-24 07:59
423 查看
try { // Executes the command. Process process = Runtime.getRuntime().exec(cmd); // NOTE: You can write to stdin of the command using // process.getOutputStream(). BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); int read; char[] buffer = new char[4096]; StringBuffer output = new StringBuffer(); while ((read = reader.read(buffer)) > 0) { output.append(buffer, 0, read); } reader.close(); // Waits for the command to finish. process.waitFor(); return output.toString(); } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } }
String mProjectName = doCommand("cat /proc/version").trim();
Log.d(TAG, "mProjectName =" + mProjectName);
相关文章推荐
- Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本
- Android: Runtime.getRuntime().exec() 的注意事项
- Android: Runtime.getRuntime().exec() 的注意事项
- Android Runtime.getRuntime().exec() 使用方法
- Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本
- Android通过Runtime.getRuntime().exec实现Ping和Traceroute命令时readLine阻塞问题解决
- Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本
- [Android] ProcessBuilder与Runtime.getRuntime().exec分别创建进程的区别
- Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本
- Android平台 Runtime.getRuntime().exec
- Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本
- Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本
- Android通过Runtime.getRuntime().exec实现Ping和Traceroute命令时readLine阻塞问题解决
- Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本
- 在apk 中执行Runtime.getRuntime().exec adb shell各种命令远程控制其他Android设备(一)
- Android ProcessBuilder与Runtime.getRuntime().exec诀别创建进程的区别
- android getruntime.exec 权限
- 在runtime.getruntime().exec调用程序时路径的问题的解决方案列表
- Runtime.getRuntime().exec()调用外部程序
- 关于Runtime.getRuntime().exec("")的参数