How to parse the string into map

后端 未结 5 1139
失恋的感觉
失恋的感觉 2021-02-15 02:24

have a string like A=B&C=D&E=F, how to parse it into map?

5条回答
  •  无人共我
    2021-02-15 03:22

    Split the string (either using a StringTokenizer or String.split()) on '&'. On each token just split again on '='. Use the first part as the key and the second part as the value.

    It can also be done using a regex, but the problem is really simple enough for StringTokenizer.

提交回复
热议问题