Android代碼執行shell 命令
android代碼 中執行shell命令的方法
private String exec(String command) {
try {
java.lang.Process process = Runtime.getRuntime().exec(command);
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();
process.waitFor();
return output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
更多相关文章
- 打开Android(安卓)Studio报错,Unable to create Channel from cla
- Android开发之android命令大全
- Android:Manifest merger failed with multiple errors, see log
- Android软键盘弹出不影响布局的方法
- Android代碼執行shell 命令
- Ubuntu .bashrc个人配置
- Android(安卓)Studio 3.6.3 中遇到无法创建FileHasher类型的服务
- Delphi XE5 android toast
- Delphi XE5 android toast