code: public static String run(File wd, String cmd, String... args) {
          // Complete list of arguments
          List<String> list = new ArrayList<>();
          list.add(cmd);
          list.addAll(Arrays.asList(args));
          try {
              LOGGER.trace("RUN WITH {}", list);
              // Builds a process
              Process process = new ProcessBuilder(list).directory(wd).start();
              // Running the process and waiting for its completion
              int exit = process.waitFor();
              LOGGER.trace("RUN EXIT {}", exit);
              // In case of error
              if (exit != 0) {
                  String error = IOUtils.toString(process.getErrorStream(), Charset.defaultCharset());
                  LOGGER.trace("RUN ERROR {}", error);
                  throw new ProcessExitException(exit, error);
              } else {
                  String output = IOUtils.toString(process.getInputStream(), Charset.defaultCharset());
                  LOGGER.trace("RUN OUT   {}", output);
                  return output;
              }
          } catch (IOException | InterruptedException ex) {
              throw new ProcessRunException("Error while executing " + cmd + " command: " + ex.getMessage());
          }
      }
docs: Runs a command in the <code>wd</code> directory and returns its output. In case of error (exit
  code different than 0), an exception is thrown.
  
  @param wd   Directory where to execute the command
  @param cmd  Command to execute
  @param args Command parameters
  @return Output of the command