Java IP Address Validate isIPv4Format(String ip)

Here you can find the source of isIPv4Format(String ip)

Description

is I Pv Format

License

Apache License

Declaration

public final static boolean isIPv4Format(String ip) 

Method Source Code

//package com.java2s;
/*/*from www.  j a v  a 2  s. c  o m*/
 * Copyright 2007-2107 the original author or authors.
 *
 * Licensed 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.Matcher;
import java.util.regex.Pattern;

public class Main {

    public final static boolean isIPv4Format(String ip) {
        Pattern patt = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
        Matcher mat = patt.matcher(ip);
        return mat.matches();
    }
}

Related

  1. isIPv4Address(final String input)
  2. isIPv4Address(final String input)
  3. isIPv4Address(String ipAddress)
  4. isIPv4AddressValid(String cidr)
  5. isIpv4Correct(String ipAddress)
  6. isIPv4Format(String str)
  7. isIPv4LiteralAddress(String src)
  8. isIPv4LiteralAddress(String string)
  9. isIpV4PortAddress(String s)