Here you can find the source of execCmd(String command)
public static String execCmd(String command)
//package com.java2s; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static String execCmd(String command) { BufferedReader br = null; StringBuffer stringBuffer = new StringBuffer(); try {/*www . j av a 2 s . co m*/ Process p = Runtime.getRuntime().exec(command); br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = null; while ((line = br.readLine()) != null) { if ("".equals(line.trim())) continue; stringBuffer.append(line); } } catch (Exception e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (Exception e) { e.printStackTrace(); } } } return stringBuffer.toString(); } }