Here you can find the source of isIpAddress(String ip)
public static boolean isIpAddress(String ip)
//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*/ }