转换 Map到分隔字符串
将 Java Map
使用番石榴的示例:
Map<String, String[]> items = new HashMap<>();
items.put("s1", new String[] {"abc", "def"});
items.put("s2", new String[] {"123", "456"});
System.out.println(Joiner.on(',').withKeyValueSeparator('=').join(items));
不要压平 String[]:
s1=**[Ljava.lang.String;@2e98be86**,s2=[Ljava.lang.String;@b676908
谢谢。
What is the best way to convert a Java Map<String, String[]> to a delimited String?
Example using guava:
Map<String, String[]> items = new HashMap<>();
items.put("s1", new String[] {"abc", "def"});
items.put("s2", new String[] {"123", "456"});
System.out.println(Joiner.on(',').withKeyValueSeparator('=').join(items));
Do not flatten the String[]:
s1=**[Ljava.lang.String;@2e98be86**,s2=[Ljava.lang.String;@b676908
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

你可以这样做:
You can do something like this: