code: public static String getUrlParentDir(String url) {
  		try {
  			UsableURI uri = UsableURIFactory.getInstance(url);
  			String path = uri.getPath();
  			if(path.length() > 1) {
  				int startIdx = path.length()-1;
  				if(path.charAt(path.length()-1) == '/') {
  					startIdx--;
  				}
  				int idx = path.lastIndexOf('/',startIdx);
  				if(idx >= 0) {
  					uri.setPath(path.substring(0,idx+1));
  					uri.setQuery(null);
                      return uri.toUnicodeHostString();
  				}
  			}
  		} catch (URIException e) {
  			LOGGER.warning(e.getLocalizedMessage() + ": " + url);
  		}
  		return null;
  	}
docs: Find and return the parent directory of the URL argument
  @param url to find the parent directory of
  @return parent directory of URL, or null, if either the url argument is
  invalid, or if the url is the root of the authority.