Here you can find the source of execIt(String cmd)
public static String execIt(String cmd)
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String execIt(String cmd) { Process process;/*from w ww. j av a 2 s.c o m*/ String result = ""; try { //cmd = "cmd /c dir"; process = Runtime.getRuntime().exec(cmd); BufferedInputStream in = new BufferedInputStream( process.getInputStream()); BufferedReader br = new BufferedReader( new InputStreamReader(in)); String lineStr; while ((lineStr = br.readLine()) != null) { result += lineStr; } br.close(); in.close(); } catch (IOException e) { e.printStackTrace(); } return result; } }