public static boolean isIPAddress(String ip){
Pattern p= Pattern.compile("([0-9]|[0-9]\\d|1\\d{2}|2[0-1]\\d|25[0-5])(\\.(\\d|[0-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}");
Matcher m = p.matcher(ip);
boolean match = m.matches();
if(!match)
{
return false;
}
return true;
}