How to identify the top level domain of a URL object using java?

java, tld, url, url-parsing

Solution

Guava provides a nice utility for this. It works as follow:

`InternetDomainName.from("someurl.co.uk").publicSuffix()` will get you `co.uk` `InternetDomainName.from("someurl.de").publicSuffix()` will get you `de`

Problem

Given this : ``` URL u=new URL("someURL"); ``` How do i identify the top level domain of the URL..

Original source