Here you can find the source of execCommand(String[] cmd)
public static String execCommand(String[] cmd) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String execCommand(String[] cmd) throws Exception { Runtime run = Runtime.getRuntime(); Process pr = null;/*from w w w .j a v a 2 s. c o m*/ try { pr = run.exec(cmd); } catch (IOException e) { e.printStackTrace(); throw e; } try { pr.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); throw e; } BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line = null; StringBuffer out = new StringBuffer(); try { while ((line = buf.readLine()) != null) { out.append(line); out.append("\n"); } } catch (IOException e) { e.printStackTrace(); throw e; } return out.toString(); } }