public  void RunCmd(String mycmd)
    {

        Process su = null;
        try {
            su = Runtime.getRuntime().exec("su");
        } catch (IOException e) {
            e.printStackTrace();
        }
        DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());

        try {
            outputStream.writeBytes(mycmd+"\n");
            outputStream.flush();

            outputStream.writeBytes("exit\n");
            outputStream.flush();
            try {
                su.waitFor();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }


    }

  

posted on 2016-01-07 17:24  小白闯天下  阅读(2112)  评论(0编辑  收藏  举报