Here you can find the source of queryStringToMap(String queryString, String charSet)
public static Map queryStringToMap(String queryString, String charSet)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.HashMap; import java.util.Map; public class Main { public static Map queryStringToMap(String queryString, String charSet) { if (queryString == null) { throw new IllegalArgumentException("queryString must be specified"); }//from w w w .ja v a 2 s. c om int index = queryString.indexOf("?"); if (index > 0) { queryString = queryString.substring(index + 1); } String[] keyValuePairs = queryString.split("&"); Map<String, String> map = new HashMap<String, String>(); for (String keyValue : keyValuePairs) { if (keyValue.indexOf("=") == -1) { continue; } String[] args = keyValue.split("="); if (args.length == 2) { try { map.put(args[0], URLDecoder.decode(args[1], charSet)); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException("invalid charset : " + charSet); } } if (args.length == 1) { map.put(args[0], ""); } } return map; } }