java执行.bat文件(收藏)
原文? http://blog.csdn.net/gavin_sw/archive/2007/01/22/1489657.aspx
try{
String exeBat = "c:\test.bat";
Process child = Runtime.getRuntime().exec(exeBat);
InputStream in = child.getInputStream();
BufferedReader br= new BufferedReader(new InputStreamReader(in));
String line = br.readLine().toString();
while(line!=null ){
??? System.out.println(line);? //输出测试
??? line = br.readLine().toString();
}
try{
??? child.waitFor();
??? br.close();
??? in.close();
}catch (Exception e) {
??? e.printStackTrace();
}
}catch (Exception e) {
??? e.printStackTrace();
}