DOSUtil
package TestLinkPackage; import java.io.BufferedReader; public class DOSUtil{ private Process process; private File workspaceFile; private File dirFile; private File buildXMLDirectory; private String workspacePath; private String buildXMLDirectoryPath; private String antCommand; public void RunDOS() { this.workspaceFile = new File(""); this.workspacePath = this.workspaceFile.getAbsolutePath(); this.dirFile = new File(this.workspacePath); File[] files = this.dirFile.listFiles(); this.buildXMLDirectoryPath = (this.workspacePath + "BuildXML"); this.buildXMLDirectory = new File(this.buildXMLDirectoryPath); File[] xmlFiles = this.buildXMLDirectory.listFiles(); this.antCommand = ("cmd.exe /c ant -buildfile " + this.buildXMLDirectoryPath + "build.xml"); if (files.length != 0) { File[] arrayOfFile1; int j = (arrayOfFile1 = files).length; for (int i = 0; i < j; i++) { File file = arrayOfFile1[i]; if (file.getName().equals("BuildXML")) { if (xmlFiles.length != 0) { File[] arrayOfFile2; int m = (arrayOfFile2 = xmlFiles).length; for (int k = 0; k < m; k++) { File xmlfile = arrayOfFile2[k]; if (xmlfile.getName().equals("build.xml")) { try { this.process = Runtime.getRuntime().exec(this.antCommand); InputStream iStream = this.process.getInputStream(); BufferedReader bReader = new BufferedReader(new InputStreamReader(iStream)); String str = null; while ((str = bReader.readLine()) != null) { System.out.println(str); } System.out.println("我已经执行了"); } catch (IOException e) { e.printStackTrace(); continue; } } else { System.out.println("build.xml文件不存在"); } } } else { System.out.println("BuildXML文件夹为空"); } } } } else { System.out.println("文件夹内容为空"); } }} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |