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

booleanstringExistInList(String value, List searchList)
string Exist In List
for (String search : searchList) {
    if (value != null && value.equals(search)) {
        return true;
    } else if (value == null && search == null) {
        return true;
return false;
...
StringstringFromLines(List lines)
string From Lines
StringBuffer buf = new StringBuffer();
for (String line : lines) {
    buf.append(line).append('\n');
return buf.toString();
StringstringFromList(List list)
Converts (any) list into a string, useful with the WebUtils#readURL(String) method
String val = "";
for (Object o : list)
    val = val + String.valueOf(o) + "\n";
return val;
StringstringfyList(List ls)
stringfy List
if (ls.isEmpty())
    return "";
String res = "[";
boolean first = true;
for (Object l : ls) {
    if (!first)
        res += ",";
    res += " " + l.toString();
...
Stringstringify(List entries)
stringify
if (entries == null || entries.isEmpty()) {
    return "";
StringBuilder stb = new StringBuilder();
for (T entry : entries) {
    stb.append(String.valueOf(entry));
    stb.append(",");
return stb.substring(0, stb.length() - 1); 
StringstringifyList(List items)
stringify List
StringBuffer buf = new StringBuffer();
for (String s : items) {
    buf.append(s);
    buf.append(ITEM_SEP);
return (buf.toString());
StringstringList(String prefix, String suffix, String separator, Object... objects)
Constructs a list of items in a string form using a prefix and suffix to denote the start and end of the list and a separator string in between the items.
StringBuilder builder = new StringBuilder(prefix);
for (int i = 0; i < objects.length; i++) {
    builder.append(objects[i].toString());
    if (i < objects.length - 1) {
        builder.append(separator);
builder.append(suffix);
...
StringstringList2String(final String suffix, final List list)
string List String
if (list == null || list.isEmpty()) {
    return null;
StringBuilder builder = new StringBuilder("");
for (int i = 0; i < list.size(); i++) {
    String value = list.get(i);
    if (value != null && !"".equals(value)) {
        if (i < (list.size() - 1)) {
...
StringstringList2String(List list, String separator)
Return list of strings in a single string separated by a separator string.
String ret = "";
for (String s : list) {
    ret += s + separator;
return ret.substring(0, ret.length() - separator.length());
booleanstringListEquals(List left, List right)
Tests if two arrays of strings have the same members irrespective of order.
if (left.size() != right.size()) {
    return false;
if (left.size() == 0) {
    return true;
List<String> copyOfLeft = new ArrayList<String>(left);
List<String> copyOfRight = new ArrayList<String>(right);
...