Java Utililty Methods Array to String

List of utility methods to do Array to String

Description

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

Method

StringarrayToString(String[] lengthsAndDelimiters)
array To String
String string = "";
for (String str : lengthsAndDelimiters) {
    string += str;
    string += "comma";
return string;
StringarrayToString(String[] lines, String separator)
array To String
StringBuilder builder = new StringBuilder();
String prefix = "";
for (String s : lines) {
    builder.append(prefix).append(s);
    prefix = separator;
return builder.toString();
StringarrayToString(String[] ngram)
Convert an array to a String using spaces as glue
String ret = "";
for (String aNgram : ngram) {
    ret += ngram + " ";
return ret.trim();
StringarrayToString(String[] object)
array To String
String s = Arrays.toString(object);
s = s.replaceAll("\\[|\\]", "");
return s;
StringarrayToString(String[] s, String delim)
Array to string.
StringBuffer buf = new StringBuffer();
for (int i = 0; i < s.length; i++) {
    buf.append(s[i]).append(delim);
return buf.toString().substring(0, buf.length() - 1);
StringarrayToString(String[] str, char sep)
Convert a string array to a string separated by some char.
if (str == null)
    return null;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length; i++) {
    sb.append(str[i]);
    sb.append(sep);
return sb.toString();
...
StringarrayToString(String[] str, String separator)
Convert String[] to String
StringBuilder result = new StringBuilder();
if (str.length > 0) {
    result.append(str[0]);
    for (int i = 1; i < str.length; i++) {
        result.append(separator);
        result.append(str[i]);
return result.toString();
StringarrayToString(String[] stringArray)
array To String
if (stringArray == null) {
    return "NULL";
if (stringArray.length == 0) {
    return "[]";
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append('[');
...
StringarrayToString(String[] stringArray)
produces a single String representation of a stringArray.
StringBuilder stringRep = new StringBuilder();
stringRep.append("[");
for (int i = 0; i < stringArray.length; i++) {
    stringRep.append(stringArray[i]);
    if (i < stringArray.length) {
        stringRep.append(",");
stringRep.append("]");
return stringRep.toString();
StringarrayToString(String[] strings)
array To String
StringBuffer result = new StringBuffer("");
if ((strings != null) && (strings.length > 0)) {
    for (int i = 0; i < strings.length; i++) {
        result.append(strings[i]);
        if (i < strings.length - 1) {
            result.append(", ");
return result.toString();