I used the URL class in Java to retrieve the hostname portion of a URL as follows.
IE, if the URL is https://hostname.mycompany.com, I want the output to just be 'hostname'
URL host = new URL(url);
String hostname = site.getHost().split("\\.")[0];
Is there an easier way to do this? Thanks.
The getHost function returns 'hostname.company.com' instead of 'hostname'