public static String [ ] getHostSegments ( URL url ) { String host = url . getHost ( ) ; // return whole hostname, if it is an ipv4 // TODO : handle ipv6 if ( IP_PATTERN . matcher ( host ) . matches ( ) ) return new String [ ] { host } ; return host . split ( "\\." ) ; }
Partitions of the hostname of the url by .