JAVA 调用exe程序执行对应的文件

try {

Runtime rt = Runtime.getRuntime(); 

   Process pr = rt.exec("D:\\BPA\\BIN\\pfnt.exe D:\\BPA\\SAMPLE\\aaa\\aaa"); // cmd /c calc 

   // Process pr = rt.exec("D:\\xunlei\\project.aspx"); 

  

   BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream(), "GBK")); 

   

   String line = null; 

  

   while ((line = input.readLine()) != null) { 

    System.out.println(line); 

   } 

  

   int exitVal = pr.waitFor(); 

   System.out.println("Exited with error code " + exitVal); 

  

} catch (Exception  e) {

System.out.println(e.toString()); 

e.printStackTrace(); 

}

猜你喜欢

转载自liyunfei241.iteye.com/blog/2412181
今日推荐