public static void waitForProcessOutput(Process self,Appendable output,Appendable error){
  Thread tout=consumeProcessOutputStream(self,output);
  Thread terr=consumeProcessErrorStream(self,error);
  try {
    tout.join();
  }
 catch (  InterruptedException ignore) {
  }
  try {
    terr.join();
  }
 catch (  InterruptedException ignore) {
  }
  try {
    self.waitFor();
  }
 catch (  InterruptedException ignore) {
  }
  closeStreams(self);
}

public static void waitForProcessOutput ( Process self , Appendable output , Appendable error ) { Thread tout = consumeProcessOutputStream ( self , output ) ; Thread terr = consumeProcessErrorStream ( self , error ) ; try { tout . join ( ) ; } catch ( InterruptedException ignore ) { } try { terr . join ( ) ; } catch ( InterruptedException ignore ) { } try { self . waitFor ( ) ; } catch ( InterruptedException ignore ) { } closeStreams ( self ) ; }
gets the output and error streams from a process and reads them to keep the process from blocking due to a full output buffer . the processed stream data is appended to the supplied appendable . for this , two threads are started , but join ( ) ed , so we wait . as implied by the waitfor . . . name , we also wait until we finish as well . finally , the input , output and error streams are closed .
