Here you can find the source of stringToMap(String src)
Parameter | Description |
---|---|
src | the original string |
public static Map<String, String> stringToMap(String src)
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { /**// w w w .j av a 2 s .c om * Convert a string of key/val pairs to a map. * * @param src the original string * @return the map */ public static Map<String, String> stringToMap(String src) { Map<String, String> ret = new HashMap<String, String>(); String[] params = src.split(";"); for (String param : params) { int ei = param.indexOf("="); if (ei == -1) { continue; } String key = param.substring(0, ei).trim(); String val = param.substring(ei + 1); ret.put(key, val); } return ret; } }