获取url里的host

public static String getHost(String urlString) {
  int index = urlString.indexOf("://");
  if (index != -1) {
   urlString = urlString.substring(index + 3);
  }
  index = urlString.indexOf("/");
  if (index != -1) {
   urlString = urlString.substring(0, index);
  }
  return urlString;
 }

你可能感兴趣的:(host)