Here you can find the source of isIpAddress(String ipAddress)
public static boolean isIpAddress(String ipAddress)
//package com.java2s; //License from project: Open Source License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static Pattern VALID_IPV4_PATTERN = null; private static Pattern VALID_IPV6_PATTERN = null; public static boolean isIpAddress(String ipAddress) { Matcher m1 = VALID_IPV4_PATTERN.matcher(ipAddress); if (m1.matches()) { return true; }//from w ww. j a v a 2 s . com Matcher m2 = VALID_IPV6_PATTERN.matcher(ipAddress); return m2.matches(); } }