用java.lang.Runtime 类调用exec方法执行doc 语句

解决方案 »

  1.   

    Process prs = Runtime.getRuntime().exec("cmd /c ping ip");
      

  2.   

    //创建runtime实例
              Runtime runtime = Runtime.getRuntime();
              Process process = null;
              String as = '"' + key + '"';
              String execCommand = "ping IP " ;
              process = runtime.exec(execCommand);
              //process.waitFor();
              is = process.getInputStream();
              isr = new InputStreamReader(is);
              br = new BufferedReader(isr);
              for (int i = 0; i < 4; i++) {
                if (br.readLine() != null) {
                  line = br.readLine();
                }
                if (i == 1) {
                  status = Integer.parseInt(line.substring(29, 30));
    //              System.out.println("-status----"+status);
                }
              }
      

  3.   

    我只想得到ping一个地址所需要的时间,不是把ping命令执行完的所有信息都得到
    不知道怎么做?/
      

  4.   

    ping前打印系统时间,ping后再打印一次,使用System.currentTimeMillis();