首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

java 运作bat并获取返回结果

2012-07-28 
java 运行bat并获取返回结果public void runbat(String timeFortmat) {String cmd cmd /c C:// + time

java 运行bat并获取返回结果

public void runbat(String timeFortmat) {           String cmd = "cmd /c C://" + timeFortmat + ".bat";           Runtime runtime = Runtime.getRuntime();           Process child = null;            try {               child = runtime.exec(cmd);               InputStream in = child.getInputStream();               String output = null;               int isSuccessful = 0;               BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));                  output=bufferedReader.readLine();                  while(output!= null){                      System.out.println(output);                      output=bufferedReader.readLine();                  }                                 try {                   //isSuccessful = child.waitFor();               } catch (Exception e) {                   e.printStackTrace();               }              } catch (IOException ioe) {               ioe.printStackTrace();           }finally{               child.destroy();           }           System.out.println("------------>ok");       } 

热点排行