public class IPUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
ILLEGAL_IP_PREFIX |
static String |
IP_PORT_SPLITER |
static String |
IPV6_END_MARK |
static String |
IPV6_START_MARK |
static String |
PERCENT_SIGN_IN_IPV6 |
static boolean |
PREFER_IPV6_ADDRESSES |
static int |
SPLIT_IP_PORT_RESULT_LENGTH |
| 构造器和说明 |
|---|
IPUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
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 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 resultCopyright © 2018–2022 Alibaba Group. All rights reserved.