java调用windows应用程序

public static void main(String[] args) {
		Runtime rt = Runtime.getRuntime();
		int exitVal = 0;
		try {
			Process proc = rt.exec("D:\\PlayCtrl\\Player.exe");
			InputStream es = proc.getErrorStream();
			InputStreamReader reader = new InputStreamReader(es);
			BufferedReader br = new BufferedReader(reader);
		   	StringBuffer sb = new StringBuffer();
		   	String l = "";
		   	while((l = br.readLine()) != null){
		    	sb.append(l+"\n");
		   	}
		   	System.out.println(sb.toString());
		   	exitVal = proc.waitFor();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(exitVal);
	 }

你可能感兴趣的:(java)