Why does InetAddress.isReachable return false, when I can ping the IP address?

后端 未结 10 1585
陌清茗
陌清茗 2020-11-22 12:24
InetAddress byName = InetAddress.getByName("173.39.161.140");
System.out.println(byName);
System.out.println(byNam         


        
10条回答
  •  独厮守ぢ
    2020-11-22 12:38

    Or using this way:

    public static boolean exists(final String host)
    {
       try
       {
          InetAddress.getByName(host);
          return true;
       }
       catch (final UnknownHostException exception)
       {
          exception.printStackTrace();
          // Handler
       }
       return false;
    }
    

提交回复
热议问题