Java external Process error stream readLine() blocks intermittently -
i shelling external windows program updates progress repeatedly pushing new lines error stream.
the command prompt looks when it's running:
10% done 10% done 11% done
and forth.
i'm having success capturing in java application thusly:
process process = runtime.getruntime().exec("my little command"); bufferedreader stdinput = new bufferedreader(new inputstreamreader(process.getinputstream())); bufferedreader stderror = new bufferedreader(new inputstreamreader(process.geterrorstream())); string s; while((s = stderror.readline())!=null) { system.out.println(s); }
unfortunately, may have guessed, there's bit of problem. stderror.readline()
blocks until there +- 4000 bytes in error stream, , prints each line out in quick session, before hangs again.
i've tried changing bufferedreader
buffer size, , using stderror.read(char [] cbuf, int off, int len)
with small length, no avail.
how fix hanging issue?
thanks in advance :)
the stderror.readline() blocks until there +- 4000 bytes in error stream
no doesn't. returns there line read.
what happening source process buffering output, evidently 4096-byte chunks. there's nothing can @ java end.
Comments
Post a Comment