如何从java应用程序在Android设备上运行strace命令
我无法从java应用程序运行strace命令 我试过上面的代码如何从java应用程序在Android设备上运行strace命令,java,android,strace,Java,Android,Strace,我无法从java应用程序运行strace命令 我试过上面的代码 try { // Executes the command. java.lang.Process process = Runtime.getRuntime().exec("strace -p 2545 -o /mnt/sdcard/Result.txt"); BufferedReader reader = new BufferedReader( new InputStreamRead
try {
// Executes the command.
java.lang.Process process = Runtime.getRuntime().exec("strace -p 2545 -o /mnt/sdcard/Result.txt");
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
// Waits for the command to finish.
process.waitFor();
output.toString() ;
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
能请你帮忙吗?我的android版本是2.2,内核版本是2.6.32.9,错误是什么?没有输出或错误消息,甚至应该存储结果的“result.txt”也没有创建:(
output.toString();
这一行什么都没有。你是说System.out.println(output.toString())
?