I want to be able to execute an external command from java, eg "ls", and get the output, both output and error streams, as a string, and in realtime, and in the order they were generated.
So, if the output from the command is something like:
blah <- to stdout
foo <- to stderr
bar <- to stdout
Then, ideally I want the output string, and the realtime output, to look like:
blah
foo
bar
Naive methods produce either:
blah
bar
(ie no stderr output)
or:
blah
bar
foo
(ie the order is rearranged so that the stdout and stderr messages are not interlaced with each other).