String to HashMap JAVA

后端 未结 10 1338
我寻月下人不归
我寻月下人不归 2020-12-02 11:32

I have a Java Property file and there is a KEY as ORDER. So I retrieve the VALUE of that KEY using the getProperty(

10条回答
  •  旧时难觅i
    2020-12-02 12:03

    You can to use split to do it:

     String[] elements = s.split(",");
     for(String s1: elements) {
         String[] keyValue = s1.split(":");
         myMap.put(keyValue[0], keyValue[1]);
     }
    

    Nevertheless, myself I will go for guava based solution. https://stackoverflow.com/a/10514513/1356883

提交回复
热议问题