public static void executeCommand(ProcessBuilder p) throws IOException {
  Process proc=p.start();
  try (BufferedReader stdInput=new BufferedReader(new InputStreamReader(proc.getInputStream()));BufferedReader stdError=new BufferedReader(new InputStreamReader(proc.getErrorStream()))){
    logger.info("Standard output of the command:\n");
    String s;
    while ((s=stdInput.readLine()) != null) {
      logger.info(s);
    }
    logger.info("Standard error of the command (if any):\n");
    while ((s=stdError.readLine()) != null) {
      logger.info(s);
    }
  }
 }

public static void executeCommand ( ProcessBuilder p ) throws IOException { Process proc = p . start ( ) ; try ( BufferedReader stdInput = new BufferedReader ( new InputStreamReader ( proc . getInputStream ( ) ) ) ; BufferedReader stdError = new BufferedReader ( new InputStreamReader ( proc . getErrorStream ( ) ) ) ) { logger . info ( "Standard output of the command:\n" ) ; String s ; while ( ( s = stdInput . readLine ( ) ) != null ) { logger . info ( s ) ; } logger . info ( "Standard error of the command (if any):\n" ) ; while ( ( s = stdError . readLine ( ) ) != null ) { logger . info ( s ) ; } } }
method to execute process
