java 检测 ip地址 是否是 通的 ,即 Ping 操作


private static final int timeOut = 3000; //超时应该在3钞以上
    
    public static boolean isPing(String ip)
    {
        boolean status = false;
        if(ip != null)
        {
            try
            {
                status = InetAddress.getByName(ip).isReachable(timeOut);
            }
            catch(UnknownHostException e)
            {
                
            }
            catch(IOException e)
            {
                
            }
        }
         return status;
    }

猜你喜欢

转载自gmleegmlee.iteye.com/blog/1328690