Android examples for java.lang:String Join
serialize Map<String,?> To String
import java.util.List; import java.util.Map; public class Main{ public static String serializeToString(Map<String, ?> data) { StringBuilder result = new StringBuilder(); int index = 0; for (Map.Entry<String, ?> e : data.entrySet()) { String key = e.getKey(); String value = toString(e.getValue()); value = value.replace("\n", "\\n"); // we use new lines as separators result.append(key);/*from w ww. ja va 2 s . c o m*/ result.append(':'); result.append(value); if (++index < data.size()) { result.append("\n"); } } return result.toString(); } }