Here you can find the source of isIp(Object obj)
public static boolean isIp(Object obj)
//package com.java2s; import java.util.regex.*; public class Main { public static final String IP_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 isIp(Object obj) { return matches(IP_PATTERN, obj); }//from w w w . j av a 2s. co m private static boolean matches(String pattern, Object obj) { Matcher matcher = Pattern.compile(pattern).matcher(String.valueOf(obj)); return matcher.matches(); } }