subdomains on a domain. Can someone help me?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • onequestion
    New Member
    • Dec 2007
    • 8

    subdomains on a domain. Can someone help me?

    Hi friends..

    Is it possible to find subdomains on a domain. Can someone help me?

    currently i'm using this code..


    Code:
    private static String GetSubDomain(URL url)             
        {
                  String host = url.getHost().toString();
             Pattern p = Pattern.compile("[.]");
            String u[]=p.split(url.getAuthority());
            if (u.length > 2)
              {
                int lastIndex = host.lastIndexOf(".");
               int index = host.lastIndexOf(".", lastIndex - 1);
             
               return host.substring(0, index);
             }
                 return null;
        }
    but it is not working for some domains like http://www.mail.yahoo. co.in and http://www2.austin.cc. tx.us

    Any help will be greatly appreciated.. thanks
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    What do you mean by "it doesn't work"? Does it "miss" sections of the url that should be listed.
    What are you considering a domain and what a subdomain? When you get down to it, pretty much everything is a subdomain. thescripts is a subdomain of the .COM domain. And you can trace higher to the arpa domains and such too.

    Comment

    Working...