Java IP Address Validate isIPv4Address(final String input)

Here you can find the source of isIPv4Address(final String input)

Description

is I Pv Address

License

Apache License

Declaration

public static boolean isIPv4Address(final String input) 

Method Source Code


//package com.java2s;
/*// w  ww .j  a  va  2  s  .c om
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */

import java.util.regex.Pattern;

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

    public static boolean isIPv4Address(final String input) {
        return IPV4_PATTERN.matcher(input).matches();
    }
}

Related

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