public int waitFor() throws InterruptedException {
  int r=process.waitFor();
  if (input != null)   input.join();
  if (output != null)   output.join();
  if (error != null)   error.join();
  process.destroy();
  return r;
}

public int waitFor ( ) throws InterruptedException { int r = process . waitFor ( ) ; if ( input != null ) input . join ( ) ; if ( output != null ) output . join ( ) ; if ( error != null ) error . join ( ) ; process . destroy ( ) ; return r ; }
wait for the process to complete , and all pending output to finish .
