Here you can find the source of parseQueryString(String query)
public static Map<String, String> parseQueryString(String query)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.LinkedHashMap; import java.util.Map; public class Main { /**/*from ww w . j a v a 2 s.co m*/ * Parse the given query string into a Map. * The order of first appearance is preserved. If a query string entry * has no "value" (i.e. no equals sign), its entirety is used as the key. */ public static Map<String, String> parseQueryString(String query) { Map<String, String> ret = new LinkedHashMap<String, String>(); for (String entry : query.split("&")) { String[] parts = entry.split("=", 2); String key, value; try { key = URLDecoder.decode(parts[0], "utf-8"); if (parts.length == 1) { value = null; } else { value = URLDecoder.decode(parts[1], "utf-8"); } } catch (UnsupportedEncodingException exc) { // Should not happen. throw new RuntimeException(exc); } ret.put(key, value); } return ret; } }