public static void main(String[] args) {
String IP="192.168.12.4" ;
boolean b=false;if(IP.matches("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}")){
String s[] = IP.split("\\.");
if(Integer.parseInt(s[0])<256)
if(Integer.parseInt(s[1])<256)
if(Integer.parseInt(s[2])<256)
if(Integer.parseInt(s[3])<256)
b = true;
}
System.out.println(b);
}