Here you can find the source of mapToStr(Map
Parameter | Description |
---|---|
map | The Map of name/value pairs |
public static String mapToStr(Map<String, String> map)
//package com.java2s; //License from project: Open Source License import java.net.URLEncoder; import java.util.Iterator; import java.util.Map; import java.util.Set; public class Main { /**// w ww .j a v a2s.c o m * Creates an encoded String from a Map of name/value pairs (MUST BE * STRINGS!) * * @deprecated * @param map * The Map of name/value pairs * @return String The encoded String */ public static String mapToStr(Map<String, String> map) { if (map == null) return null; StringBuffer buf = new StringBuffer(); Set<String> keySet = map.keySet(); Iterator<String> i = keySet.iterator(); boolean first = true; while (i.hasNext()) { Object key = i.next(); Object value = map.get(key); if (!(key instanceof String) || !(value instanceof String)) continue; String encodedName = URLEncoder.encode((String) key); String encodedValue = URLEncoder.encode((String) value); if (first) first = false; else buf.append("|"); buf.append(encodedName); buf.append("="); buf.append(encodedValue); } return buf.toString(); } }