java get domain from url

Solutions on MaxInterview for java get domain from url by the best coders in the world

showing results for - "java get domain from url"
Yannick
21 Feb 2018
1public static String getDomainName(String url) throws URISyntaxException {
2    URI uri = new URI(url);
3    String domain = uri.getHost();
4    return domain.startsWith("www.") ? domain.substring(4) : domain;
5}
6