code: public static Map<URLParts, String> splitURL(URL url) {
          Map<URLParts, String> urlParts = new HashMap<>();
          
          urlParts.put(URLParts.PROTOCOL, url.getProtocol());
          urlParts.put(URLParts.USERINFO, url.getUserInfo());
          urlParts.put(URLParts.AUTHORITY, url.getAuthority());
          urlParts.put(URLParts.HOST, url.getHost());
          urlParts.put(URLParts.PATH, url.getPath());
          urlParts.put(URLParts.QUERY, url.getQuery());
          urlParts.put(URLParts.FILENAME, url.getFile());
          urlParts.put(URLParts.REF, url.getRef());
          int port = url.getPort();
          if(port!=-1) {
              urlParts.put(URLParts.PORT, String.valueOf(port));
          }
          else {
              urlParts.put(URLParts.PORT, null);
          }
          
          return urlParts;
      }
docs: This method splits a URL into parts and return a map containing them.
  
  @param url
  @return