I have a file which I convert it into List<List<String>>
After doing this, I do some processing and then I need the file (which is now a List
of List
) to be converted into a string.
private static String convertListOfListToString(List<List<String>> listOfIncomingMsgListsTemp){
List<String> tempList = new ArrayList<String>();
for(List<String> listOfString : listOfIncomingMsgListsTemp){
tempList.add(convertListToString(listOfString));
}
String modifiedString = convertListToString(tempList);
modifiedString.replace("\n\n", "\n");
System.out.println("modifiedString :\n" + modifiedString);
return modifiedString;
}
private static String convertListToString(List<String> list){
StringBuilder sb = new StringBuilder();
for (String s : list)
{
sb.append(s);
sb.append("\n");
}
return(sb.toString());
}
Output : When I append List , 2 \n\n are appended. I need to remove those and have only 1 \n. how can I do that?