阅读背景:

如何使管道与运行时.exec()一起工作?

来源:互联网 

Consider the following code:

考虑下面的代码:

String commandf = "ls /etc | grep release";

try {

    // Execute the command and wait for it to complete
    Process child = Runtime.getRuntime().exec(commandf);
    child.waitFor();

    // Print the first 16 bytes of its output
    InputStream i = child.getInputStream();
    byte[] b = new byte[16];
    i.read(b, 0, b.length); 
    System.out.println(new String(b));

} catch (IOException e) {
    e.printStackTrace();
    System.exit(-1);
}
Strin



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: