Need help parsing...
In my code, I have a method that returns url.getHost();. But the results of that can be blarg.com, or sometimes dates.blarg.com. I want to retur
Using split:
String host = url.getHost(); String[] items = host.split("\\."); if(items.length>2) host = items[items.length-2] + '.' + items[items.length-1];
Using indexes:
String host = url.getHost(); while(host.indexOf('.')!=host.lastIndexOf('.')) { host = host.substring(host.indexOf('.') + 1); }