使用ROOT 反回执行结果
String su(String su){String r=;
try
{
java.lang.Process p = Runtime.getRuntime().exec("su");
DataOutputStream o = new DataOutputStream(p.getOutputStream());
o.writeBytes(new StringBuffer().append(su).append("\n").toString());
o.writeBytes("exit\n");
o.flush();
StringBuilder i = new StringBuilder(),e = new StringBuilder();
BufferedReader
in = new BufferedReader(new InputStreamReader(p.getInputStream())),
er = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String s;
while ((s = in.readLine()) != null)
{
i.append(s);
}
while ((s = er.readLine()) != null)
{
e.append(s);
}
p.getErrorStream().close();
r=i.toString();
}catch (IOException e){}
return r;
} 本帖最后由 djwdj 于 2017-10-29 15:07 编辑
String su(String su){
String r=;
try
{
java.lang.Process p = Runtime.getRuntime().exec("su");
DataOutputStream d = new DataOutputStream(p.getOutputStream());
d.writeBytes(new StringBuffer().append(su).append("\n").toString());
d.writeBytes("exit\n");
d.flush();
StringBuilder i = new StringBuilder();
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
String s;
while ((s = b.readLine()) != null)
{
i.append(s);
}
p.getErrorStream().close();
r=i.toString();
}catch (IOException e){}
return r;
} 没说明,直接一段代码?太简洁了。。。
页:
[1]