Answers for "java how toget the domain name from url"

1

java get domain from url

public static String getDomainName(String url) throws URISyntaxException {
    URI uri = new URI(url);
    String domain = uri.getHost();
    return domain.startsWith("www.") ? domain.substring(4) : domain;
}
Posted by: Guest on August-18-2021

Code answers related to "java how toget the domain name from url"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language