Here you can find the source of stringToMap(String str)
public static Map<String, String> stringToMap(String str)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; public class Main { public static Map<String, String> stringToMap(String str) { Map<String, String> res = new HashMap<String, String>(); int start = 0; int index; while (start < str.length()) { index = str.indexOf(',', start); if (index < 0) { index = str.length();/*from www . j a v a2 s. com*/ } String col = str.substring(start, index).trim(); start = index + 1; if (col.length() > 0) { index = col.indexOf(':'); String name = col; String value = ""; if (index >= 0) { name = col.substring(0, index).trim(); value = col.substring(index + 1).trim(); } res.put(name, value); } } return res; } }