class UrlUtils {

  public static Map<String, List<String>> getQueryParameters(URL url)
      throws UnsupportedEncodingException {
    Map<String, List<String>> params = new HashMap<>();
    String query = url.getQuery();
    if (query != null) {
      for (String param : query.split("&")) {
        String pair[] = param.split("=");
        String key = URLDecoder.decode(pair[0], "UTF-8");
        String value = null;
        if (pair.length > 1) {
          value = URLDecoder.decode(pair[1], "UTF-8");
        }
        List<String> values = params.get(key);
        if (values == null) {
          values = new ArrayList<>();
          params.put(key, values);
        }
        values.add(value);
      }
    }
    return params;
  }

  private  UrlUtils();

}