Here you can find the source of executeCommandLineReturnAll( final String[] command)
public static String[] executeCommandLineReturnAll( final String[] command)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.io.InputStreamReader; import java.io.BufferedReader; public class Main { public static String[] executeCommandLineReturnAll( final String[] command) { final ArrayList<String> al = new ArrayList<String>(); try {/*from w w w . j a v a2s . co m*/ final Runtime rt = Runtime.getRuntime(); rt.traceInstructions(true); rt.traceMethodCalls(true); final Process p = rt.exec(command); final BufferedReader data = new BufferedReader( new InputStreamReader(p.getInputStream())); final BufferedReader error = new BufferedReader( new InputStreamReader(p.getErrorStream())); String line; while ((line = data.readLine()) != null) { al.add(line); } while ((line = error.readLine()) != null) { al.add(line); } data.close(); error.close(); } catch (Exception e) { System.out.println("Problem executing -> " + stringArrayToString(command, " ") + " " + e.getLocalizedMessage()); e.printStackTrace(); return null; } final String[] res = new String[al.size()]; al.toArray(res); return res; } public static String stringArrayToString(final String[] s, final String separator) { if (s == null) { return ""; } final int len = s.length; if (len == 1) { return s[0]; } if (len == 0) { return ""; } final StringBuffer sb = new StringBuffer(s[0]); for (int i = 1; i < len; ++i) { sb.append(separator); sb.append(s[i]); } return sb.toString(); } }