Here you can find the source of isIP(String str)
public static boolean isIP(String str)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isIP(String str) { String num = "(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)"; String regex = "^" + num + "\\." + num + "\\." + num + "\\." + num + "$"; return match(regex, str); }/*from w w w .ja va2s. co m*/ private static boolean match(String regex, String str) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); } }