版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/songyanfei1205/article/details/81483321
/**@PARAM command指exe程序所在路径**/
public static String executeCmd(String command) throws IOException {
System.err.println("Execute command : " + command);
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("cmd /c start " + command);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
String line = null;
StringBuilder build = new StringBuilder();
while ((line = br.readLine()) != null) {
System.err.println(line);
build.append(line);
}
return build.toString();
}