Here you can find the source of StringToMap(String str)
public static HashMap<String, String> StringToMap(String str)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); you may import java.util.HashMap; public class Main { public static HashMap<String, String> StringToMap(String str) { return StringToMap(str, "\\n", "="); }//w w w. ja v a 2s.c om public static HashMap<String, String> StringToMap(String str, String outter, String inner) { //chop the string into tokens using the outter delimiter first, typically \n String[] tokens = str.split(outter); HashMap<String, String> map = new HashMap<String, String>(); for (int i = 0; i < tokens.length; i++) { //skip comments if (tokens[i].startsWith(";")) continue; //chop the string further by inner delimiter, typically = String[] strings = tokens[i].split(inner); if (strings.length == 2) map.put(strings[0], strings[1]); } return map; } }