Java IP Address Validate isIpV4Address(CharSequence address)

Here you can find the source of isIpV4Address(CharSequence address)

Description

is Ip V Address

License

Apache License

Declaration

public static boolean isIpV4Address(CharSequence address) 

Method Source Code

//package com.java2s;
/*/*from  w w w .  ja  v a2 s  . co  m*/
 * Copyright 2015-2017 the original author or authors
 *
 * This software is licensed under the Apache License, Version 2.0,
 * the GNU Lesser General Public License version 2 or later ("LGPL")
 * and the WTFPL.
 * You may choose either license to govern your use of this software only
 * upon the condition that you accept all of the terms of either
 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
 */

import java.util.regex.Pattern;

public class Main {
    private final static Pattern IPV4_PATTERN = Pattern
            .compile("\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z");

    public static boolean isIpV4Address(CharSequence address) {
        if (address == null) {
            return false;
        }
        return IPV4_PATTERN.matcher(address).matches();
    }
}

Related

  1. isIPAndPort(String text)
  2. isIpFormat(String ip)
  3. isIPSect(String ip)
  4. isIPString(String str)
  5. isIpv4(String ipv4)
  6. isIPv4Address(final String input)
  7. isIPv4Address(final String input)
  8. isIPv4Address(String ipAddress)
  9. isIPv4AddressValid(String cidr)