code: public static String getHost(String uriString) {
          try {
              URI uri = new URI(uriString);
              if(uri.getHost()==null) {
                  throw new IllegalArgumentException("Invalid URI syntax. Scheme and host must be provided (port number is optional): " + uriString);
              }
              if (uri.getAuthority().startsWith("@") && !uri.getHost().startsWith("@")) {
                  return "@" + uri.getHost();
              }
              return uri.getHost();
          }
          catch (URISyntaxException e) {
              try {
                  return (new NetworkInterfaceURI(uriString)).getHost();
              }
              catch (IllegalArgumentException ne) {
                  throw new IllegalArgumentException(ne.getMessage(), ne);
              }
          }
      }
docs: Helper method for retrieving host
  @param uriString
  @return