简体   繁体   中英

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)?

echo path | ./app

Is this the same as starting the app and then writing to STDIN?

I want to be able to start a process from Java and destroy it (and not worry about child processes)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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