Here you can find the source of explodeDomains(final String fqdn)
public static String[] explodeDomains(final String fqdn)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static String[] explodeDomains(final String fqdn) { final String[] explodedFqdn = fqdn.split("\\."); if (explodedFqdn.length == 1) { return explodedFqdn; }// ww w.j a va 2 s. c om final ArrayList<String> fqdns = new ArrayList<>(); String subFqdn = explodedFqdn[explodedFqdn.length - 2] + "." + explodedFqdn[explodedFqdn.length - 1]; fqdns.add(subFqdn); for (int i = explodedFqdn.length - 3; i >= 0; i--) { subFqdn = explodedFqdn[i] + "." + subFqdn; fqdns.add(subFqdn); } return fqdns.toArray(new String[fqdns.size()]); } }