private boolean execute(String command,File arg,List<String> lines){
  ProcessBuilder pb=new ProcessBuilder(command,arg.getAbsolutePath());
  pb.redirectErrorStream(true);
  try {
    Process proc=pb.start();
    BufferedReader reader=new BufferedReader(new InputStreamReader(proc.getInputStream()));
    String line;
    while ((line=reader.readLine()) != null) {
      lines.add(line);
    }
    proc.waitFor();
    return proc.exitValue() == 0;
  }
 catch (  Exception e) {
    log.error("Exception while executing: " + command + " "+ arg,e);
    lines.add(e.getMessage());
    return false;
  }
}

private boolean execute ( String command , File arg , List < String > lines ) { ProcessBuilder pb = new ProcessBuilder ( command , arg . getAbsolutePath ( ) ) ; pb . redirectErrorStream ( true ) ; try { Process proc = pb . start ( ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( proc . getInputStream ( ) ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { lines . add ( line ) ; } proc . waitFor ( ) ; return proc . exitValue ( ) == 0 ; } catch ( Exception e ) { log . error ( "Exception while executing: " + command + " " + arg , e ) ; lines . add ( e . getMessage ( ) ) ; return false ; } }
executes a command with one argument , returning true if the command succeeds . gathers the output from stdout and stderr into the provided list of lines .
