H
horos22
All,
I'm using the following idiom to get stderr and stdout from a java
process (iterating first over stderr, and then over stdout), and am
running into a world of hurt.
What is happening is that the input stream seems to be 'getting
stuck'; ie: my guess is some internal buffer associated with the
InputStream fills up for stdout which causes the first loop to hang.
So my question is - is there a way to 'interleave' the output from the
two input streams?
Ed
(
btw - what follows is the source for doing this..the code stalls on
the br_out.readLine() line..
)
Process proc = Runtime.getRuntime().exec(_mycmd);
InputStream stderr = proc.getErrorStream ();
InputStream stdout = proc.getInputStream ();
BufferedReader br_err = new BufferedReader (new InputStreamReader
(stderr));
BufferedReader br_out = new BufferedReader (new InputStreamReader
(stdout));
while ((line = br_err.readLine ()) != null) { .. }
while ((line = br_out.readLine()) != null) { .. }
I'm using the following idiom to get stderr and stdout from a java
process (iterating first over stderr, and then over stdout), and am
running into a world of hurt.
What is happening is that the input stream seems to be 'getting
stuck'; ie: my guess is some internal buffer associated with the
InputStream fills up for stdout which causes the first loop to hang.
So my question is - is there a way to 'interleave' the output from the
two input streams?
Ed
(
btw - what follows is the source for doing this..the code stalls on
the br_out.readLine() line..
)
Process proc = Runtime.getRuntime().exec(_mycmd);
InputStream stderr = proc.getErrorStream ();
InputStream stdout = proc.getInputStream ();
BufferedReader br_err = new BufferedReader (new InputStreamReader
(stderr));
BufferedReader br_out = new BufferedReader (new InputStreamReader
(stdout));
while ((line = br_err.readLine ()) != null) { .. }
while ((line = br_out.readLine()) != null) { .. }