Process process = Runtime.getRuntime().exec("c:\\test.bat"); // 执行一个系统命令 InputStream fis = process.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); String line = null; StringBuffer cmdout = new StringBuffer(); while ((line = br.readLine()) != null) { cmdout.append(line).append(System.getProperty("line.separator")); } br.close(); process.destroy(); System.out.print(cmdout.toString().trim()); int result = 0; if (cmdout.toString().contains("BUILD SUCCESSFUL")) { result = 1; System.out.println("\n" + "result =" + result); } System.out.print("----" + System.getProperty("line.separator"));
时间: 2024-10-27 17:03:55