Java IP Address Validate isIpAddress(String addr)

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

Description

is Ip Address

License

Apache License

Declaration

public static boolean isIpAddress(String addr) 

Method Source Code

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

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

public class Main {

    public static boolean isIpAddress(String addr) {
        if (addr.length() < 7 || addr.length() > 15 || "".equals(addr)) {
            return false;
        }//w  ww .  ja  v a2  s . c  o m
        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;
    }
}

Related

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