Java Utililty Methods List to String

List of utility methods to do List to String

Description

The list of methods to do List to String are organized into topic(s).

Method

StringlistToString(List list)
list To String
return listToString("", list, ", ", "");
StringlistToString(List list, String prefix, String delimiter, String suffix)
list To String
String listStr = prefix;
boolean isFirst = true;
for (T element : list) {
    listStr += (isFirst ? "" : delimiter) + element.toString();
    isFirst = false;
listStr += suffix;
return listStr;
...
StringlistToString(List list, String sep)
list To String
if (list == null || list.isEmpty())
    return null;
int size = list.size();
StringBuilder sb = new StringBuilder();
int count = 0;
for (T str : list) {
    sb.append(str.toString());
    if (count < size - 1)
...
StringlistToString(String itemName, List list)
list To String
StringBuffer buffer = new StringBuffer("\n\t< " + itemName + " >\n");
Iterator iterator = list.iterator();
for (; iterator.hasNext();) {
    buffer.append("\t\t< ").append(iterator.next().toString()).append(" >\n");
buffer.append("\t< " + itemName + " >");
return buffer.toString();
ListtoString(final List list)
to String
final List<String> strings = new ArrayList<String>(list.size());
for (Object o : list)
    strings.add(o.toString());
return strings;
StringtoString(final List list, final String separtor)
To string.
final StringBuffer buf = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
    final Object object = list.get(i);
    buf.append(object.toString());
    if (i < list.size() - 1) {
        buf.append(separtor);
return buf.toString();
StringtoString(final List list)
to String
return toString(list, "\t");
StringtoString(final List inMessages)
to String
if (inMessages.isEmpty()) {
    return "No errors detected";
final StringBuilder builder = new StringBuilder();
Integer index = 0;
for (String msg : inMessages) {
    if (index == 0) {
        builder.append('\n');
...
StringtoString(final List input)
to String
final StringBuilder command = new StringBuilder();
for (Iterator<String> iterator = input.iterator(); iterator.hasNext();) {
    String fragment = iterator.next();
    command.append(fragment);
    if (iterator.hasNext()) {
        command.append(" ");
return command.toString();
StringtoString(final List list, char delimiter)
Convert a list of strings to a string separated by delimiter
final StringBuilder b = new StringBuilder();
if (list != null) {
    for (int i = 0; i < list.size(); i++) {
        b.append(list.get(i));
        if (i != list.size() - 1) {
            b.append(delimiter);
return b.toString();