code: public static String getBaseURL(String url) {
  		URL u = toURL(url);
  		String base = null;
  		if (u != null) {
  			try {
  				base = u.toURI().getScheme().concat("://").concat(u.getAuthority());
  			} catch (URISyntaxException ex) {
  				base = null;
  			}
  		}
  		return base;
  	}
docs: The basic URL without any parameters: &gt;scheme&lt;:&gt;authority&lt;.
  @param url a full URL
  @return the basic URL