I am using ProcessBuilder to invoke an external command which will provide me the output. And I'm supplying input through String Buffer. My program works fine for 2934 strings within StringBuffer. However, the moment my stringbuffer size goes beyond 2934, the program hangs & waits forever.
Below is my code.
Can anyone tell me what could be the issue? Is there any limit in String Buffer? If so, how to resolve it?
PS: I also tried specifying large capacity such as 99999 in constructor of String buffer but still no luck....
Yes....I'm in fact giving input of 9000 strings within String Buffer.
Using , I'm actually capturing the output of the external utility which I am calling using ProcessBuilder.
Can you please help?
It looks like the buffer cannot accommodate much data. I just tried replacing String Buffer with Array List but the problem stays the same. So, it could be related to the output stream being not able to handle much data.
ok....I just noticed that the program works fine for small chunk of strings say 500 strings. However, if I use more than this limit, it just hangs at line process.waitFor().
After doing more analysis, I noticed that the process is hanging because the I/O buffer is full...And it should be released by reading it.
If I try the below code, it works fine...But again it also has the limitation of processing around 8000 strings.....and thats not the right approach since I'm reading it before even knowing whether the process has finished it or not....So is there any other better soln???
Still no luck....Tried reading both error & input streams before waiFor....it hangs....When I do the Ctrl-C, it gives below error:
And if I look at the line number 2990 from above error, it seems like the issue is somewhere else.....Basically, when I'm throwing the string as an input to this external utility, it is hanging there itself....
Code hangs at Line 2990 which is writer.write(lst);