Java String Explode explodeDomains(final String fqdn)

Here you can find the source of explodeDomains(final String fqdn)

Description

explode Domains

License

Open Source License

Declaration

public static String[] explodeDomains(final String fqdn) 

Method Source Code

//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()]);
    }
}

Related

  1. explode(String src, String sep)
  2. explode(String string, String separators)
  3. explode(String tokenizer, String text)
  4. explode(String[] elements, String separator)
  5. explodeCamelCase(String str, boolean excludeGetOrSet)
  6. explodeLongs(String line, String sep)
  7. explodeQuoted(String arg)