Convert java Map to custom key=value string

前端 未结 4 1405
感动是毒
感动是毒 2021-02-13 04:16

I have TreeMap which I need to convert to URI-like string and then back to Map. I need to set custom delimiters.

Is there any tool (Gu

4条回答
  •  轮回少年
    2021-02-13 04:53

    its not guava or apache commons, and it is a loop, but aside from instantiating the string builder, it is a one liner:

    for (Entry entry : myMap.entrySet()) {
        sb.append(entry.getKey() + separator + entry.getValue() + "\n");
    }
    

提交回复
热议问题