private boolean isIP(String ip) {
if (ip == null || "".equals(ip)) {
return false;
}
String regex = "((25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\.){3}"
+ "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)$";
return ip.matches(regex);
}
参考链接: