Given a list
List l = new ArrayList();
l.add(\"one\");
l.add(\"two\");
l.add(\"three\");
I have a method
<
I don't know any Apache String joiner that can support adding and in the joined String.
Here's an untested code that will do what you asked:
public static String join(String separator, List mList, boolean includeAndInText) {
StringBuilder sb = new StringBuilder();
int count = 0;
for (String m: mList) {
if (includeAndInText && (count + 1 != mList.size())) {
sb.append (" and ");
}
sb.append(m);
count++;
if (count < mList.size()) {
sp.append(separator);
}
}
return sb.toString();
}