Runtime calls cmd / cd commands

Runtime run = Runtime.getRuntime();
String command = "cmd /c cd /d C:/workspace/TestApp && mvn clean install -Dmaven.test.skip";
// use && to link two dos command; also we can define a bat file, then calling this file via cmd

BufferedReader br = new BufferedReader(new InputStreamReader(run.exec(command).getInputStream(), "UTF-8"));
String str = "";
while((str = br.readLine()) != null)
System.out.println(str);

br.close();

 

posted @ 2013-05-08 11:01  甲甲  阅读(128)  评论(0编辑  收藏  举报