public static ArrayList < String > runProcess ( String ... commands ) throws InterruptedException , IOException { final java . lang . ProcessBuilder processBuilder = new java . lang . ProcessBuilder ( commands ) ; final ArrayList < String > output = new ArrayList <> ( ) ; final Process process = processBuilder . start ( ) ; process . waitFor ( ) ; final InputStream inputStream = process . getInputStream ( ) ; try { final java . io . BufferedReader reader = new java . io . BufferedReader ( new InputStreamReader ( inputStream , StandardCharsets . UTF_8 ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { output . add ( line ) ; } } finally { inputStream . close ( ) ; } return output ; }
Run a sequence of commands