zoukankan      html  css  js  c++  java
  • RootCommand

    RootCommnd  /system/bin/sh    /system/xbin/su

    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    
    	public void RootCommand(String cmd) {
    		Process process = null;
    		DataOutputStream os = null;
    		DataInputStream is = null;
    		try {
    			process = Runtime.getRuntime().exec("su");
    			os = new DataOutputStream(process.getOutputStream());
    			os.writeBytes(cmd + "
    ");
    			os.writeBytes("exit
    ");
    			os.flush();
    			int aa = process.waitFor();
    			is = new DataInputStream(process.getInputStream());
    			byte[] buffer = new byte[is.available()];
    			is.read(buffer);
    			String out = new String(buffer);
    			Log.d("gatsby", out);
    		} catch (Exception e) {
    			e.printStackTrace();
    		} finally {
    			try {
    				if (os != null) {
    					os.close();
    				}
    				if (is != null) {
    					is.close();
    				}
    				process.destroy();
    			} catch (Exception e) {
    			}
    		}
    	}
    

      

      

      

  • 相关阅读:
    IE11浏览器:请不要再叫我IE,谢谢
    Hadoop HA高可用搭建流程
    YARN
    MapReduce
    HDFS
    shell
    shell总结
    linux总结
    maven+log4j
    Spring
  • 原文地址:https://www.cnblogs.com/crushgirl/p/14334039.html
Copyright © 2011-2022 走看看