Java IP Address Validate isIpAddress(String ip)

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

Description

is Ip Address

License

Apache License

Declaration

public static boolean isIpAddress(String ip) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static final String IPADDRESS_PATTERN = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
            + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
            + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";

    public static boolean isIpAddress(String ip) {
        Pattern pattern = Pattern.compile(IPADDRESS_PATTERN);
        Matcher matcher = pattern.matcher(ip);
        return matcher.matches();
    }/*  w w  w .jav  a 2 s. com*/
}

Related

  1. isIp(String str)
  2. isIp(String str)
  3. isIP4(String val)
  4. isIPAddress(final String s)
  5. isIpAddress(String addr)
  6. isIPAddress(String ipAddress)
  7. isIpAddress(String ipAddress)
  8. isIpAddress(String ipAddress)
  9. isIPAddress(String ipAddress)