80,351
社区成员
发帖
与我相关
我的任务
分享
String command = "rm /data/***"; // the command that will be execute
Runtime runtime = Runtime.getRuntime();
Process proc = null;
try {
proc = runtime.exec(command);
} catch (IOException e1) {
e1.printStackTrace();
}
// put a BufferedReader on the ps output
InputStream inputstream = proc.getInputStream();
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
// read the ps output and show it to screen.
...
...
// judge the return value
try {
if (proc.waitFor() != 0) {
System.err.println("exit value = " + proc.exitValue());
}
}
catch (InterruptedException e) {
System.err.println(e);
}