public static boolean isValidIPAddress ( String networkAddress ) { if ( networkAddress != null ) { String [ ] split = networkAddress . split ( "\\." ) ; if ( split . length == 4 ) { int [ ] octets = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { try { octets [ i ] = Integer . parseInt ( split [ i ] ) ; } catch ( NumberFormatException e ) { return false ; } if ( octets [ i ] < 0 || octets [ i ] > 255 ) { return false ; } } return true ; } } return false ; }
Verify if a given string is a valid dotted quad notation IP Address