gpt4 book ai didi

java - 如何获取某个IP地址的ping时间?

转载 作者:行者123 更新时间:2023-12-02 06:58:19 25 4
gpt4 key购买 nike

我是 Mac 用户,通过终端使用 ping 命令来测量 ping 时间(以毫秒为单位)。我想创建一个 Java 应用程序,只需输入 IP 即可获取 ping 响应时间。

我知道我可以使用 InetAddress判断IP是否可达,但是如何判断ping时间呢?

最佳答案

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

}catch(Exception e){}
}

关于java - 如何获取某个IP地址的ping时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17014003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com