我是 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/