I have a hashmap with a String key and List(String) as values.
For Example:
Key | Values
John | GroupName1,GroupName2,GroupName3
Nick | Groupname4,GroupName1
I would like to write this hashmap to a csv file such that my csv file contains rows as below:
John,GroupName1,GroupName2,GroupName3
Nick,Groupname4,GroupName1
I tried:
Map<String, List<String>> usersmap = (Map<String, List<String>>) model.get("users"); //this is my map
StringWriter output = new StringWriter();
ICsvListWriter listWriter;
listWriter = new CsvListWriter(output, CsvPreference.STANDARD_PREFERENCE);
for (Map.Entry<String, List<String>> entry : usersmap.entrySet()) {
listWriter.write(entry.getKey(), entry.getValue());
}
but it doesn't seem right to me.