Java调用cmd 命令

public static boolean execCmd(String cmd) {
	Process proc = null;
	try {
		proc = Runtime.getRuntime().exec(cmd);
		proc.waitFor();

		if (proc.waitFor() == 0) {
			// System.out.println("exit code:" + proc.exitValue());
			if (proc.exitValue() == 0){
				return true;
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	} finally {
		if(proc!=null){
			proc.destroy();
		}
	}
	return false;
}