I am trying to write a Java program that will execute a line of code on the Windows command prompt. I would like to use an external program (7-Zip) to extract some RAR files (it's more complicated than that but it doesn't matter for the problem at hand).
I got the Runtime instance and used the .exec() method. It works fine when I try to extract one archive by itself but when I try to extract many at the same time, the process gets hung up and .waitFor() never returns.
I researched the problem and believe it is being caused by the output the process is producing. It seems that some buffer or another is filling up and locking up the program. I was outlined here. I implemented this solution (except I used an imput stream and directed it to a file) and it did indeed work. However, it seems to take a lot of extra time to write all that completely unnecessary output.
I was wondering if there was a way to trick the BufferedReader into thinking it has written all that is in its buffer without actually writing it?
Thanks for reading all the way to the bottom!