ProcessUtils { public static String run(String... command) throws IOException { final Process process = new ProcessBuilder(command).start(); try (InputStream stream = process.getInputStream(); InputStreamReader reader = new InputStreamReader(stream); BufferedReader bufferedReader = new BufferedReader(reader) ) { final StringBuilder output = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { output.append(line); } return output.toString(); } }  static String run(String... command); static ProcessStats getProcessStats();  }
@Test public void run() throws Exception { final String expectedOutput = "Have a nice day."; final String output = ProcessUtils.run("/bin/echo", expectedOutput); Assert.assertEquals(output, expectedOutput); }