Java Utililty Methods IP Address Validate

List of utility methods to do IP Address Validate

Description

The list of methods to do IP Address Validate are organized into topic(s).

Method

booleanisIp(String str)
is Ip
boolean result = validByRegex(
        "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",
        str);
return result;
booleanisIp(String str)
is Ip
return regex(str, REGEX_IP);
booleanisIP4(String val)
is IP
boolean result = false;
Pattern p = Pattern.compile(IP4_REGEXP);
Matcher m = p.matcher(val);
try {
    return m.matches();
} catch (Exception e) {
    e.printStackTrace();
return result;
booleanisIPAddress(final String s)
Returns whether the supplied string represents an IP address.
return s != null && (IPV4_PATTERN.matcher(s).matches() || IPV6_STD_PATTERN.matcher(s).matches()
        || IPV6_HEX_COMPRESSED_PATTERN.matcher(s).matches());
booleanisIpAddress(String addr)
is Ip Address
if (addr.length() < 7 || addr.length() > 15 || "".equals(addr)) {
    return false;
String rexp = "([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}";
Pattern pat = Pattern.compile(rexp);
Matcher mat = pat.matcher(addr);
boolean ipAddress = mat.find();
return ipAddress;
...
booleanisIpAddress(String ip)
is Ip Address
Pattern pattern = Pattern.compile(IPADDRESS_PATTERN);
Matcher matcher = pattern.matcher(ip);
return matcher.matches();
booleanisIPAddress(String ipAddress)
is IP Address
if (ipAddress == null)
    return false;
Pattern pattern = Pattern.compile("\\b" + "((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\."
        + "((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\."
        + "((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\."
        + "((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])" + "\\b");
Matcher matcher = pattern.matcher(ipAddress);
return matcher.matches();
...
booleanisIpAddress(String ipAddress)
Determine if the given string is a valid IPv4 or IPv6 address.
Matcher m1 = VALID_IPV4_PATTERN.matcher(ipAddress);
if (m1.matches()) {
    return true;
Matcher m2 = VALID_IPV6_PATTERN.matcher(ipAddress);
return m2.matches();
booleanisIpAddress(String ipAddress)
is Ip Address
Matcher m1 = VALID_IPV4_PATTERN.matcher(ipAddress);
if (m1.matches()) {
    return true;
Matcher m2 = VALID_IPV6_PATTERN.matcher(ipAddress);
return m2.matches();
booleanisIPAddress(String ipAddress)
is IP Address
return Pattern.matches(
        "^[1-9](\\d{1,2})?\\.(0|([1-9](\\d{1,2})?))\\.(0|([1-9](\\d{1,2})?))\\.(0|([1-9](\\d{1,2})?))$",
        ipAddress);