android 执行shell 组件 源码 多命令共用进程版v1.1
java.lang.Process su;public String cmd(String cmd)
{
String s="";
try
{
if(su==null)
{
su=Runtime.getRuntime().exec("su");
}
OutputStream o=su.getOutputStream();
o.write((cmd+"\n").getBytes());
o.flush();
InputStream is=su.getInputStream();
byte[] b = new byte;
s=new String(b,0,is.read(b)).trim();
}
catch (IOException e)
{}
return s;
}
页:
[1]