Convert java Map to custom key=value string

前端 未结 4 1412
感动是毒
感动是毒 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:42

    According to David Tulig you could do it in guava via

     String string = Joiner.on("|").withKeyValueSeparator("_").join(map);
    

    The opposite is also available via

     Map map = Splitter.on("|").withKeyValueSeparator("_").split(string);
    

提交回复
热议问题