Check whether the ipAddress is in private range

前端 未结 4 490
执笔经年
执笔经年 2021-02-07 06:43

How would I check to see whether the ip address is in private category ?

    if(isPrivateIPAddress(ipAddress)) {
                


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-02-07 07:00

    The correct method is InetAddress.isSiteLocalAddress().

    Utility routine to check if the InetAddress is a site local address.

    Returns: a boolean indicating if the InetAddress is a site local address; or false if address is not a site local unicast address.

提交回复
热议问题