Here you can find the source of toMap(String s)
public static Map<String, String> toMap(String s)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; public class Main { public static Map<String, String> toMap(String s) { Map<String, String> map = new HashMap<String, String>(); if (isNull(s)) return map; String[] ss = toArray(s, ";"); for (int i = 0; i < ss.length; i++) { String[] value = toArray(ss[i], "="); if (value.length == 1) value = toArray(ss[i], ","); map.put(value[0], value[1]); }/* w ww. j a va 2s. c om*/ return map; } public static boolean isNull(Object s) { if (s == null || s.toString().trim().length() == 0 || s.equals("null")) return true; else return false; } public static String[] toArray(String s) { return toArray(s, ","); } public static String[] toArray(String s, String delim) { if (isNull(s)) return new String[0]; return s.split(delim); } }