public static InetAddress getByAddress ( String addr ) throws UnknownHostException { byte [ ] bytes ; bytes = toByteArray ( addr , IPv4 ) ; if ( bytes != null ) return InetAddress . getByAddress ( bytes ) ; bytes = toByteArray ( addr , IPv6 ) ; if ( bytes != null ) return InetAddress . getByAddress ( bytes ) ; throw new UnknownHostException ( "Invalid address: " + addr ) ; }
Converts an address from its string representation to an IP address . The address can be either IPv4 or IPv6 .