Is there an effective way to convert java map values to comma separated string using guava or StringUtils?
Map<String, String> testMap = new HashMap<>();
testMap.put("key1", "val1");
testMap.put("key2", "val2");
looking for a way to convert testMap to a String -> "val1,val2".
OK, here's my guess in case you want something like this (there's no clarification in your Question). This is done without Guava or StringUtils:
Output:
If you want to display the
valuesas a comma separated list, you could use this:Output:
PS: Remove the
[]s with.replaceAll()if you want