public class InternetAddressUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
ILLEGAL_IP_PREFIX |
static String |
IP_PORT_SPLITER |
static String |
IPV6_END_MARK |
static String |
IPV6_START_MARK |
static String |
LOCAL_HOST |
static String |
PERCENT_SIGN_IN_IPV6 |
static boolean |
PREFER_IPV6_ADDRESSES |
static int |
SPLIT_IP_PORT_RESULT_LENGTH |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
bytesToInt(byte[] bytes)
convert byte array to int.
|
static String |
checkIPs(String... ips)
Check ips.
|
static boolean |
checkOK(String checkIPsResult)
Check whether checkIPs result is "ok".
|
static boolean |
containsPort(String address)
Check if the address contains a port. 2020/9/3 14:53
|
static String |
getIPFromString(String str)
Resolve the IP from the string containing the IP address.
|
static byte[] |
ipToBytesByInet(String ip)
convert ip address to byte array.
|
static int |
ipToInt(String ip)
convert ip address to int.
|
static boolean |
isDomain(String str)
judge str is right domain.
|
static boolean |
isIP(String addr)
check whether the str is ip address (IPv4 or IPv6).
|
static boolean |
isIPv4(String addr)
check whether the ip address is IPv4.
|
static boolean |
isIPv6(String addr)
check whether the ip address is IPv6.
|
static String |
localHostIP()
get localhost ip.
|
static String |
removeBrackets(String str)
remove brackets "[]".
|
static String[] |
splitIPPortStr(String str)
Split IP and port strings, support IPv4 and IPv6, IP in IPv6 must be enclosed with [].
|
public static final boolean PREFER_IPV6_ADDRESSES
public static final int SPLIT_IP_PORT_RESULT_LENGTH
public static String localHostIP()
public static boolean isIPv4(String addr)
addr - ip addresspublic static boolean isIPv6(String addr)
addr - ip addresspublic static boolean isIP(String addr)
addr - ip address strpublic static boolean containsPort(String address)
address - address stringpublic static String[] splitIPPortStr(String str)
str - ip and port stringpublic static String getIPFromString(String str)
str - string containing IP addresspublic static String checkIPs(String... ips)
ips - ipspublic static boolean checkOK(String checkIPsResult)
checkIPsResult - checkIPs resultpublic static String removeBrackets(String str)
str - is ipv6 addresspublic static boolean isDomain(String str)
str - nacosIPpublic static int ipToInt(String ip)
ip - ip address.public static int bytesToInt(byte[] bytes)
bytes - byte array.public static byte[] ipToBytesByInet(String ip)
ip - ip address.Copyright © 2018–2024 Alibaba Group. All rights reserved.