Here you can find the source of executeCmdCommand(String command)
private static String executeCmdCommand(String command) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { private static String executeCmdCommand(String command) throws IOException { System.out.println("Execute " + command); ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", command);/*from w w w . j av a2s . c o m*/ // builder.redirectErrorStream(true); Process p = builder.start(); BufferedReader r = new BufferedReader(new InputStreamReader( p.getInputStream())); StringBuilder result = new StringBuilder(); String line; while (true) { line = r.readLine(); if (line == null) { break; } result.append(line); System.out.println(line); } return result.toString(); } }