如何从java应用程序在Android设备上运行strace命令

时间:2013-04-17 15:25:30

标签: 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 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

0 个答案:

没有答案