Java URL Query Build getQueryMap(String query)

Here you can find the source of getQueryMap(String query)

Description

get Query Map

License

Open Source License

Declaration

private static Map<String, String> getQueryMap(String query) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

import java.net.URLDecoder;

import java.util.*;

public class Main {
    private static Map<String, String> getQueryMap(String query) {
        String[] params = query.split("&");
        Map<String, String> map = new HashMap<>();
        for (String param : params) {
            String name = null;/*  w  ww  . j  ava2  s . c o m*/
            final String[] paramParts = param.split("=");
            try {
                name = URLDecoder.decode(paramParts[0], "utf-8");
            } catch (UnsupportedEncodingException e) {
                // Impossible
            }
            String value = null;
            try {
                value = URLDecoder.decode(paramParts[1], "utf-8");
            } catch (UnsupportedEncodingException e) {
                // Impossible
            }
            map.put(name, value);
        }
        return map;
    }
}

Related

  1. createQueryStringForParameters(Map parameters)
  2. createQueryStringFromMap(Map m, String ampersand, boolean encode)
  3. getQuery(Map params, String encode)
  4. getQuery(URL theURL)
  5. getQueryFromURL(URL url)
  6. getQueryMap(String urlString)
  7. getQueryMap(URL url)
  8. getQueryParameter(String query, String key, String encoding)
  9. getQueryParameterMap(String queryString)