runtiemexec("cmd /c ping ");就可以的!!!!

解决方案 »

  1.   

    //你可以使用java.lang.Runtime 类。
    Runtime rt = Runtime.getRuntime();
    try {
       /* 
        * 以下代码使用Runtime类在一个subprocess中运行所在平台
        * 的native命令。
        */ 
       Process ps = rt.exec("ping www.yahoo.com");   /* 
        * ping命令的output会定向到subprocess的InputStream。
        * 得到此InputStream, 然后输出到你希望的地方。
        */
       InputStream is = ps.getInputStream();
       int t;
       while ((t=is.read()) != -1){
        System.out.print((char)t);
       }
    } catch (Exception se) {}//当然程序还需要一些优化。