public static boolean validateAgaintIPAdressV4Format ( final String input ) { if ( input == null ) { return false ; } int hitDots = 0 ; char [ ] data = input . toCharArray ( ) ; for ( int i = 0 ; i < data . length ; i ++ ) { char c = data [ i ] ; int b = 0 ; do { if ( c < ' ' || c > ' ' ) { return false ; } b = ( b * 10 + c ) - 48 ; if ( ++ i >= data . length ) { break ; } c = data [ i ] ; } while ( c != ' ' ) ; if ( b > 255 ) { return false ; } hitDots ++ ; } return hitDots == 4 ; }
Checks given string against IP address v4 format .