0

我是 Mac 用户,通过终端使用 ping 命令测量 ping 时间(以毫秒为单位)。我想创建一个 Java 应用程序,我可以在其中简单地输入 ip 并获取 ping 响应时间。

我知道我可以用它InetAddress来确定 IP 是否可达但我如何确定 ping 时间?

4

1 回答 1

2
public void ping (String entryIpAddress){
    try{    
         String command ="ping  "+entryIpAddress;
         Process process = Runtime.getRuntime().exec(command);
         process.getOutputStream();

    }catch(Exception e){}
}
于 2013-06-09T22:03:38.307 回答