public static boolean isIPv4 ( final String ip ) { if ( StringUtils . isBlank ( ip ) ) { return false ; } final String regex = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ; final Pattern pattern = Pattern . compile ( regex ) ; final Matcher matcher = pattern . matcher ( ip ) ; return matcher . matches ( ) ; }
Is IPv4 .