//获取域名的函数 //包含全部的cn域名后缀 static String[] xCN = { ".com.cn", ".net.cn", ".gov.cn", ".edu.cn", ".org.cn", ".mil.cn", ".ac.cn", ".bj.cn", ".sh.cn", ".tj.cn", ".cq.cn", ".he.cn", ".sx.cn", ".nm.cn", ".ln.cn", ".jl.cn", ".hl.cn", ".js.cn", ".zj.cn", ".ah.cn", ".fj.cn", ".jx.cn", ".sd.cn", ".ha.cn", ".hb.cn", ".hn.cn", ".gd.cn", ".gx.cn", ".hi.cn", ".sc.cn", ".gz.cn", ".yn.cn", ".xz.cn", ".sn.cn", ".gs.cn", ".qh.cn", ".nx.cn", ".xj.cn", ".tw.cn", ".hk.cn", ".mo.cn" }; public static String getHost1(String host) { host = host.trim().toLowerCase();//格式化 String domain1 = ""; if (host.endsWith(".cn")) { //判断cn分类域名以及区域域名 for (int i = 0; i < xCN.length; i++) { if (host.endsWith(xCN[i])) { host = host.substring(0, host.length() - xCN[i].length()); String[] _s = host.split("\\."); if (_s.length > 0) { domain1 = _s[_s.length - 1] + xCN[i]; } return domain1; } } //else if(host.endsWith(".cn")){ host = host.substring(0, host.length() - 3); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".cn"; //} } else if (host.endsWith(".com")) { host = host.substring(0, host.length() - 4); String[] _s = host.split("\\."); domain1 = _s[_s.length - 1] + ".com"; } else if (host.endsWith(".net")) { host = host.substring(0, host.length() - 4); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".net"; } else if (host.endsWith(".org")) { host = host.substring(0, host.length() - 4); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".org"; } else if (host.endsWith(".gov")) { host = host.substring(0, host.length() - 4); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".gov"; } else if (host.endsWith(".edu")) { host = host.substring(0, host.length() - 4); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".edu"; } else if (host.endsWith(".biz")) { host = host.substring(0, host.length() - 4); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".biz"; } else if (host.endsWith(".tv")) { host = host.substring(0, host.length() - 3); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".tv"; } else if (host.endsWith(".cc")) { host = host.substring(0, host.length() - 3); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".cc"; } else if (host.endsWith(".be")) { host = host.substring(0, host.length() - 3); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".be"; } else if (host.endsWith(".info")) { host = host.substring(0, host.length() - 5); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".info"; } else if (host.endsWith(".name")) { host = host.substring(0, host.length() - 5); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".name"; } else if (host.endsWith(".co.uk")) { host = host.substring(0, host.length() - 6); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".co.uk"; } else if (host.endsWith(".me.uk")) { host = host.substring(0, host.length() - 6); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".me.uk"; } else if (host.endsWith(".org.uk")) { host = host.substring(0, host.length() - 7); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".org.uk"; } else if (host.endsWith(".ltd.uk")) { host = host.substring(0, host.length() - 7); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".ltd.uk"; } else if (host.endsWith(".plc.uk")) { host = host.substring(0, host.length() - 7); String[] _s = host.split("\\."); if (_s.length > 0) domain1 = _s[_s.length - 1] + ".plc.uk"; } return domain1; }