Nam Ha Minh wrote:My question is, why don't some program send its output to the input stream but error stream, like the FFmpeg program? How can we know which stream to which the program sends output?
If I call process.waitFor(), then the program seems to be waiting forever. Why?
Nam Ha Minh wrote:Thanks Paul for your insight,
The Java doc of waitFor() method does not tell that I have to consume the process' output stream when calling waitFor(). So I thought the waitFor() method will block the program until the process finished without writing any additional code.
So is my thought wrong?
Paul Clapham wrote: You should read the classic article When Runtime.exec() won't and implement all of its recommendations.
Tony Docherty wrote:Yes it is a great article. It saved my skin many a year ago and I've also been recommending it ever since.
Not that this will effect the operation of the code but I believe the current recommended way to create a Process is to use ProcessBuilder rather than Runtime.
Mike Simmons wrote:Also, one could use ProcessBuilder rather than Runtime.exec(). Just a thought.
Mike Simmons wrote:I was feeling like we're in a loop. I recommended using ProcessBuilder here a week ago, above.
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|