Here you can find the source of stringToMap(String input)
private static Map<String, Object> stringToMap(String input)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.HashMap; import java.util.Map; public class Main { private static Map<String, Object> stringToMap(String input) { Map<String, Object> map = new HashMap<String, Object>(); String[] nameValuePairs = input.split("&"); for (String nameValuePair : nameValuePairs) { String[] nameValue = nameValuePair.split("="); try { if (isParsable(nameValue[1])) { map.put(URLDecoder.decode(nameValue[0], "UTF-8"), (int) Integer.parseInt(nameValue[1])); } else { map.put(URLDecoder.decode(nameValue[0], "UTF-8"), nameValue.length > 1 ? URLDecoder.decode(nameValue[1], "UTF-8") : ""); }/*from ww w .j a v a2s .c o m*/ } catch (UnsupportedEncodingException e) { throw new RuntimeException("This method requires UTF-8 encoding support", e); } } return map; } public static boolean isParsable(String input) { boolean parsable = true; try { Integer.parseInt(input); } catch (NumberFormatException e) { parsable = false; } return parsable; } }