[英]Read stream of an external process with Java
What I would like to know is, can I from Java read the output stream of an external process? 我想知道的是,我可以从Java中读取外部进程的输出流吗? Let us say this external process is a windows terminal and is not started from Java using ProcessBuilder or Runtime.exec().
让我们说这个外部进程是Windows终端,不是使用ProcessBuilder或Runtime.exec()从Java启动的。
It is possible if the external process is a predecessor in a process pipeline: 如果外部流程是流程管道中的前身,则有可能:
> cat file | java MyClass
then java program can read the output stream of the cat
program via System.in
. 然后java程序可以通过
System.in
读取cat
程序的输出流。 In other cases, I doubt it is possible even using C/C++ languages. 在其他情况下,我怀疑甚至可以使用C / C ++语言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.