Java Utililty Methods String to Map

List of utility methods to do String to Map

Description

The list of methods to do String to Map are organized into topic(s).

Method

MapstringToCharMap(String s)
string To Char Map
Map<Character, Integer> ret = new HashMap<Character, Integer>();
for (int i = 0; i < s.length(); i++) {
    ret.put(s.charAt(i), i);
return ret;
MapstringToMap(final String s)
Converts a string containing name-value pairs to a map.
if (s == null)
    return null;
final Map<String, String> m = new HashMap<String, String>();
final StringBuilder sb = new StringBuilder();
int equalSignIdx = -1;
int ampersandCount = 0;
for (char c : s.toCharArray()) {
    if (c != '&' && ampersandCount > 0) {
...
MapstringToMap(final String s)
string To Map
final Map<String, String> map = new HashMap<String, String>();
final String[] elements = s.split(";");
for (final String parts : elements) {
    final String[] keyValue = parts.split(":");
    map.put(keyValue[0], keyValue[1]);
return map;
MapstringToMap(String append)
string To Map
if (append.isEmpty()) {
    return new HashMap<>();
HashMap errs = new HashMap<>();
String[] at = append.split(", ");
for (String string : at) {
    String[] at2 = string.split(":");
    ArrayList<String> atd = new ArrayList<>();
...
MapstringToMap(String source, String delimiter)
string To Map
String[] fieldsArray = source.split(delimiter);
Map<String, String> fields = new HashMap();
if (fieldsArray.length == 4) {
    fields.put("accessKey", fieldsArray[0]);
    fields.put("digest", fieldsArray[1]);
    fields.put("date", fieldsArray[2]);
    fields.put("nonce", fieldsArray[3]);
} else {
...
HashMapstringToMap(String src)
Converts a name-value pair string into a Map object.
HashMap<String, String> dest = new HashMap<String, String>();
if (src == null) {
    return (dest);
String line, key, val;
int equalsPos, newLinePos, startPos = 0, len = src.length();
while (startPos < len) {
    newLinePos = src.indexOf('\n', startPos);
...
MapstringToMap(String src)
Convert a string of key/val pairs to a map.
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();
...
HashMapStringToMap(String str)
String To Map
return StringToMap(str, "\\n", "=");
MapstringToMap(String str)
string To Map
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();
    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;
MapstringToMap(String value)
string To Map
if (value == null || value.length() == 0)
    throw new Exception();
if (value.startsWith("{") || value.startsWith("["))
    value = value.substring(1);
if (value.endsWith("}") || value.endsWith("]"))
    value = value.substring(0, value.length() - 1);
String[] elements = value.split(",");
Map<String, String> map = new HashMap();
...