Here you can find the source of executeCommandLine(String command)
public static String[] executeCommandLine(String command) throws IOException, InterruptedException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static String[] executeCommandLine(String command) throws IOException, InterruptedException { List<String> lines = new ArrayList<String>(); String line;/* w w w.j a v a 2 s .c om*/ Process proc; proc = Runtime.getRuntime().exec(command); BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream())); while ((line = input.readLine()) != null) { lines.add(line); } input.close(); if (0 == proc.waitFor()) { // Succeeded proc.destroy(); return lines.toArray(new String[lines.size()]); } return lines.toArray(new String[0]); } }