Here you can find the source of isIp(String ip)
public static boolean isIp(String ip)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isIp(String ip) { Pattern pattern = Pattern.compile( "^([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$"); Matcher matcher = pattern.matcher(ip); return matcher.matches(); }/*from www. ja v a 2s.c o m*/ }