Java Utililty Methods String from List

List of utility methods to do String from List

Description

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

Method

StringstringListString(List list)
Static method to generate a list representation for an ArrayList of Strings S1,...,Sn
String result = "[";
for (int i = 0; i < list.size() - 1; i++) {
    result += list.get(i) + ",";
if (list.size() > 0) {
    result += list.get(list.size() - 1);
result += "]";
...
String[]stringListToArray(final List list)
string List To Array
if (list != null) {
    final String[] str = new String[list.size()];
    int i = 0;
    for (final String l : list) {
        str[i++] = l;
    return str;
return null;
Object[]stringListToArray(List list)
Converts list of strings to an array.
Object[] params = null;
if (list != null) {
    params = list.toArray(new String[list.size()]);
return params;
String[]stringListToArray(List params)
string List To Array
int paramsSize = params.size();
String returnString[] = new String[params.size()];
for (int i = 0; i < paramsSize; i++) {
    returnString[i] = params.get(i);
return returnString;
StringstringListToString(final List l, final String separator)
string List To String
final StringBuilder sb = new StringBuilder();
if ((l != null) && (l.size() > 0)) {
    for (int i = 0; i < l.size() - 1; ++i) {
        sb.append(l.get(i) + separator);
    sb.append(l.get(l.size() - 1));
return sb.toString();
...
StringstringListToString(List list)
Converts a list of strings into a single string, separated by commas.
if (list == null)
    return "";
StringBuilder sb = new StringBuilder();
for (String item : list) {
    if (sb.length() > 0) {
        sb.append(", ");
    sb.append(item);
...
StringstringListToString(List list)
string List To String
StringBuilder builder = new StringBuilder();
for (String obj : list) {
    builder.append(String.format("%s\n", obj.toString()));
return builder.toString();
StringstringListToString(List list, String delim)
string List To String
if (list == null || delim == null)
    return null;
StringBuilder result = new StringBuilder();
for (Iterator<String> it = list.listIterator(); it.hasNext();)
    result.append(it.next()).append(delim);
return new String(result);
StringstringListToString(List ls)
Utility function called from the ODM runtime to sort and format a list of strings in a consistent way
Collections.sort(ls);
return ls.toString();
StringstringListToString(List stringList, String delim)
Convert string array to string with delimeters.
StringBuilder bldr = new StringBuilder();
for (String s : stringList) {
    if (bldr.length() > 0) {
        bldr.append(delim).append(s);
    } else {
        bldr.append(s);
return bldr.toString();