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#getInputStream
和Process#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.