Here you can find the source of getHostName(String url)
Parameter | Description |
---|---|
url | Given URL |
Parameter | Description |
---|---|
URISyntaxException | an exception |
public static String getHostName(String url) throws URISyntaxException
//package com.java2s; //License from project: Apache License import java.net.URI; import java.net.URISyntaxException; public class Main { /**//from w w w . j ava2 s . co m * Gets a host from given URL * @param url Given URL * @return a host name * @throws URISyntaxException */ public static String getHostName(String url) throws URISyntaxException { URI uri = new URI(url); return uri.getHost(); } }