简体   繁体   English

执行与Java中的Linux管道相同的操作?

[英]perform same operation as linux pipe in java?

How can I do the following in Java code (without invoking the shell directly - not using the pipe operator at all)? 如何在Java代码中执行以下操作(无需直接调用外壳程序-完全不使用管道运算符)?

echo path | ./app

Is this the same as starting the app and then writing to STDIN? 这与启动应用程序然后写入STDIN一样吗?

I want to be able to start a process from Java and destroy it (and not worry about child processes) 我希望能够从Java启动一个进程并销毁它(而不必担心子进程)

您可以使用ProcessBuilder ,它包装Process以从Java应用程序启动进程,并使用Process#getInputStreamProcess#getOutputStream捕获其IO流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM