阅读更多


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);
        }
    }

 

更多相关文章

  1. 打开Android(安卓)Studio报错,Unable to create Channel from cla
  2. Android开发之android命令大全
  3. Android:Manifest merger failed with multiple errors, see log
  4. Android软键盘弹出不影响布局的方法
  5. Android代碼執行shell 命令
  6. Ubuntu .bashrc个人配置
  7. Android(安卓)Studio 3.6.3 中遇到无法创建FileHasher类型的服务
  8. Delphi XE5 android toast
  9. Delphi XE5 android toast

随机推荐

  1. android 服务service里面出Toast
  2. Android使用Retrofit请求WebService
  3. 如何正常关闭android应用程序
  4. android手机端与PC端使用adb forword通信
  5. android dex工具打包Could not reserve e
  6. android 从Activity 获取 rootView 根节
  7. android:SQlite
  8. android修改当前窗口的亮度
  9. 使用Maven开发Android
  10. android ScrollView嵌套ListView,并且实现