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

StringmapToStr(java.util.Map hm, char sep1, char sep2)
map To Str
if (hm == null || hm.isEmpty())
    return null;
StringBuffer buffer = new StringBuffer();
java.util.Iterator<java.util.Map.Entry> iter = hm.entrySet().iterator();
while (iter.hasNext()) {
    java.util.Map.Entry entry = (java.util.Map.Entry) iter.next();
    buffer.append(entry.getKey());
    buffer.append(sep1);
...
StringmapToStr(Map map)
map To Str
StringBuilder sb = new StringBuilder();
boolean isFirst = true;
sb.append("{");
for (Map.Entry<String, ?> entry : map.entrySet()) {
    if (isFirst)
        isFirst = false;
    else
        sb.append(",");
...
StringmapToStr(Map map)
map To Str
String str = "";
Set<String> keySet = map.keySet();
Iterator<String> iter = keySet.iterator();
while (iter.hasNext()) {
    String key = iter.next();
    str += key + "=" + map.get(key) + "&";
return str.substring(0, str.length() - 1);
...
StringmapToString(final Map m)
Converts a Map into a String
return m == null ? null : collectionToString(m.entrySet());
StringmapToString(final Map m)
Transforms a map to a string containing name-value pairs separated by '&'.
final StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> e : m.entrySet()) {
    sb.append(e.getKey().replace("&", "&&")).append('=');
    final String value = e.getValue();
    if (value != null)
        sb.append(e.getValue().replace("&", "&&"));
    sb.append('&');
sb.setLength(sb.length() - 1);
return sb.toString();
StringmapToString(final Map map)
map To String
String s = "";
for (final Map.Entry<String, String> entry : map.entrySet()) {
    s += entry.getKey() + ":" + entry.getValue() + ";";
if (s.length() > 0) {
    s = s.substring(0, s.length() - 1);
return s;
...
StringmapToString(Map map)
Converts the given map of objects to string as a comma-separated list.
if (map == null) {
    return "<null>";
} else if (map.isEmpty()) {
    return "<none>";
} else {
    StringBuilder s = new StringBuilder();
    Iterator iter = map.entrySet().iterator();
    while (iter.hasNext()) {
...
StringmapToString(Map map)
Outputs entries from a Map to a String .
return mapToString(map, "=", ", ");
StringmapToString(Map map)
map To String
if (map == null)
    return "null";
if (map.size() == 0)
    return "empty";
StringBuilder sb = new StringBuilder();
sb.append("{");
for (Object o : map.entrySet()) {
    Map.Entry me = (Entry) o;
...
StringmapToString(Map map)
map To String
if (map == null) {
    return null;
StringBuffer sBuffer = new StringBuffer();
Iterator keys = map.keySet().iterator();
while (keys.hasNext()) {
    Object key = keys.next();
    sBuffer.append("\n").append(key).append(" = ").append(map.get(key));
...