字符串转化map

来源:互联网 发布:国家工商局网络教学 编辑:程序博客网 时间:2024/06/04 17:55
//将以key=value&key=value。。。的字符串转换为map集合中

Map<String, String> map = new HashMap<String, String>();
String[] arr = ReturnWeiXinUrl.split("&");
for (String str : arr) {
String[] params = str.split("=");
if(params.length>1){
String key = params[0];
String value =  URLDecoder.decode(params[1], "UTF-8");
//String value =  params[1];
//System.out.println(" key  "+ key + " == " + value);
map.put(key, value); 
}
}
//获取 responseCode
responseCode = map.get("responseCode") ;
System.out.println("WeiXinWapPayOperation----->responseCode:::" + responseCode);
0 0
原创粉丝点击