Here you can find the source of exec(String... cmd)
public static String exec(String... cmd) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static String exec(String... cmd) throws Exception { StringBuffer resultBuffer = new StringBuffer(); Process pr = Runtime.getRuntime().exec(cmd); BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line;//from w ww . ja va 2 s . c o m while ((line = in.readLine()) != null) { resultBuffer.append(line + "<br />"); } in.close(); pr.waitFor(); return resultBuffer.toString(); } }