How to capture standard output from another program ?
I need the following thing and can't figure out how to do it:
I need to "wrap" a command-line program which is not a java program. My program should invoke it and then capture any output by the external program and show it in my java application (the external program outputs to standard output device). The user will not even know that I am activating another program in the background, as he/she will get all the output directly in my program.
Is it possible ? How ?
Re: How to capture standard output from another program ?
You can capture output and error streams by retrieving the Process from the Runtime.getRuntime().exec() function. Depending upon what you are running, it may be also be a good idea to do capture outputs in separate threads.