SystemUtil { static String getProcessOutput(Process p) throws IOException { BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader bre = new BufferedReader(new InputStreamReader(p.getErrorStream())); String line; StringBuilder result = new StringBuilder(); while ((line = bri.readLine()) != null) { result.append(line); } bri.close(); if (result.length() > 0) { result.append('\n'); } while ((line = bre.readLine()) != null) { result.append(line); } bre.close(); return result.toString(); }  @Deprecated static long getSystemTimeMillis(); static long getTimeBasedSeed(); static int getTimeBasedIntSeed(); static long getRelativeTimeMillis(); static long getFreeMemory(); static String getPropertyOrEnvironmentVariable(String name); static boolean runProcessAndWait(String exec, String params); static boolean runProcessAndWait(String exec, String params, String workingDirPath); static int runProcessAndGetExitCode(String exec, String params); static int runProcessAndGetExitCode(String exec, String params, String workingDirPath); static String runProcessAndGetOutput(String command, String params); static StringBuilder runProcessAndCollectErrors(String execPath, String params);  }
@Test public void getProcessOutputTest() throws IOException { String result = SystemUtil.getProcessOutput(new TestProcess()); Assert.assertEquals("This is process info\n" + "This is error info", result); }
@Test public void getProcessOutputEmptyTest() throws IOException { String result = SystemUtil.getProcessOutput(new EmptyTestProcess()); Assert.assertEquals("This is error info", result); }