Map.toString 的字串轉Map
public static void main(String[] args) { String str="{attach= sfsd , sub_mch_id=10000100, time_end=20140903131540, openid=oUpF8uMEb4qRXf22hE3X68TekukE, bank_type=CFT, return_code=SUCCESS}"; Map<String,String> map=mapStringToMap(str); } public static Map<String,String> mapStringToMap(String str){ str=str.substring(1, str.length()-1); String[] strs=str.split(","); Map<String,String> map = new HashMap<String, String>(); for (String string : strs) { String key=string.split("=")[0]; String value=string.split("=")[1]; map.put(key, value); } return map; } --------------------- 原文:https://blog.csdn.net/xu3508620/article/details/46562523 版權宣告:本文為博主原創文章,轉載請附上博文連結!