public static String socketAddressToUrlString ( InetSocketAddress address ) { if ( address . isUnresolved ( ) ) { throw new IllegalArgumentException ( "Address cannot be resolved: " + address . getHostString ( ) ) ; } return ipAddressAndPortToUrlString ( address . getAddress ( ) , address . getPort ( ) ) ; }
Encodes an IP address and port to be included in URL . in particular this method makes sure that IPv6 addresses have the proper formatting to be included in URLs .