请教高手如何用JAVA编程实现获取CMD中的PING值
例如:我在CMD中输入ping 163.com
就会得到一个时延值time=223
怎么才能用JAVA实现呢?
谢谢高手啦,急着用啊

解决方案 »

  1.   


    package org.sigon;import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.PrintStream;public class SystemTest {
    public static void main(String[] args) throws IOException {
    Process process = Runtime.getRuntime().exec("ping 163.com");  
    InputStream input = process.getInputStream();
    PrintStream print = new PrintStream(System.out);
    BufferedReader reader = new BufferedReader(new InputStreamReader(input));
    String str = reader.readLine();
    while(null != str){
    print.println(str);
    str = reader.readLine();
    }
    }
    }好久没写流了,写的比较笨,勿怪.
    这个只是取出命令结果,分析内容你自己搞定吧