Hi friends..
Is it possible to find subdomains on a domain. Can someone help me?
currently i'm using this code..
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
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;
}
Any help will be greatly appreciated.. thanks
Comment