public static String hostToPublicSuffix(String host) { InternetDomainName idn; try { idn = InternetDomainName.from(host); } catch (IllegalArgumentException e) { return host; } InternetDomainName tmp = idn.publicSuffix(); if (tmp == null) { return host; } String pubSuff = tmp.toString(); int idx = host.lastIndexOf(".", host.length() - (pubSuff.length() + 2)); if (idx == -1) { return host; } return host.substring(idx + 1); }