java get domain from url

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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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