首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

零 0 Java的Process对象 在执行命令之后一段时间再去获取InputStream

2012-12-23 
0 0 Java的Process对象 在执行命令之后一段时间再去获取InputStreamProcess pr Runtime.getRuntime().ex

0 0 Java的Process对象 在执行命令之后一段时间再去获取InputStream
    Process pr = Runtime.getRuntime().exec(finalCommand);
      BufferedReader br_in = null;
      try {
        br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
        String buff = null;
        while ( (buff = br_in.readLine()) != null) {
          System.out.println("stdout: " + buff);
          try {
            Thread.sleep(100);
          }
          catch (Exception e) {}
        }
        br_in.close();
      }
      catch (IOException ioe) {
        System.out.println("Error printing process output.");
        ioe.printStackTrace();
      }
      finally {
        try {
          br_in.close();
        }
        catch (Exception ex) {}
      }

热点排行