网上查了好多都不成功啊
运行到到 os.writeBytes(command + "\n");时老是出错啊 java.io.IOException: write failed: EPIPE (Broken pipe)
下面是程序
Process process = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec("su",null,null);
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
if (os != null) {
os.close();
}
//process.destroy();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}