Java代码
// 第一种方式:利用cmd方式
/**
* 执行cmd命令
*
* @param command
* @throws IOException
*/
public static String executeCmd(String command) throws IOException {
log.info("Execute command : " + command);
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("cmd /c " + command);
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
String line = null;
StringBuilder build = new StringBuilder();
while ((line = br.readLine()) != null) {
log.info(line);
build.append(line);
}
return build.toStri