天天看点

java 执行exe程序

/**@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();  
	}