Java Utililty Methods Map to String

List of utility methods to do Map to String

Description

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

Method

MaptoStringMap(Map map)
Transform a map to a string map.
Map<String, String> stringMap = new HashMap<>();
for (Map.Entry<?, ?> entry : map.entrySet()) {
    stringMap.put(entry.getKey().toString(), entry.getValue().toString());
return stringMap;
MaptoStringMap(Map src)
to String Map
Map<String, String> dst = new HashMap<String, String>();
Set<?> entrySet = src.entrySet();
for (Object object : entrySet) {
    if (object != null && object instanceof Entry<?, ?>) {
        Entry<?, ?> entry = (Entry<?, ?>) object;
        Object key = entry.getKey();
        Object value = entry.getValue();
        if (key != null) {
...
MaptoStringMap(Properties properties)
to String Map
Map<String, String> map = new HashMap<String, String>();
for (Object key : properties.keySet()) {
    map.put((String) key, properties.getProperty((String) key));
return map;
MaptoStringMap(String... pairs)
to String Map
Map<String, String> parameters = new java.util.HashMap<String, String>();
if (pairs.length > 0) {
    if (pairs.length % 2 != 0) {
        throw new IllegalArgumentException("pairs must be even.");
    for (int i = 0; i < pairs.length; i = i + 2) {
        parameters.put(pairs[i], pairs[i + 1]);
return parameters;
MaptoStringMap(String... pairs)
to String Map
Map<String, String> parameters = new HashMap<String, String>();
if (pairs.length > 0) {
    if (pairs.length % 2 != 0) {
        throw new IllegalArgumentException("pairs must be even.");
    for (int i = 0; i < pairs.length; i = i + 2) {
        parameters.put(pairs[i], pairs[i + 1]);
return parameters;