Here you can find the source of stringToMap(String[] strings)
Parameter | Description |
---|---|
strings | a parameter |
public static Map stringToMap(String[] strings)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; public class Main { /**/*from w w w . j a v a2 s . com*/ * Convert an array of String which likes "key=value" to a Map. * * @param strings * @return */ public static Map stringToMap(String[] strings) { Map result = new HashMap(); for (int i = 0; i < strings.length; i++) { int pos = strings[i].indexOf('='); if (pos != -1 && pos != 0 && pos != strings[i].length()) { String key = strings[i].substring(0, pos); String value = strings[i].substring(pos + 1); result.put(key, value); } } return result; } }