public static boolean isIpv4(String... ipstr){ String regIp = "^([1-9]|[1-9]\\d|1\\d{2}|2[0-1]\\d|22[0-3])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$"; for(String ip : ipstr){ boolean flag = ip.matches(regIp); if(!flag){ return false; } } return true; }