public static InetAddress InetAddressByIPv4 ( String address ) { StringTokenizer addressTokens = new StringTokenizer ( address , "." ) ; byte [ ] bytes ; if ( addressTokens . countTokens ( ) == 4 ) { bytes = new byte [ ] { getByBytes ( addressTokens ) , getByBytes ( addressTokens ) , getByBytes ( addressTokens ) , getByBytes ( addressTokens ) } ; } else { return null ; } try { return InetAddress . getByAddress ( bytes ) ; } catch ( UnknownHostException e ) { return null ; } }
Convert defined string to IPv4 object instance