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[] strs)
Given an array of strings, return a comma-separated list of its elements.
if (strs.length == 0) {
    return "";
StringBuffer sbuf = new StringBuffer();
sbuf.append(strs[0]);
for (int idx = 1; idx < strs.length; idx++) {
    sbuf.append(",");
    sbuf.append(strs[idx]);
...
StringarrayToString(String[] strs)
Given an array of strings, return a comma-separated list of its elements.
if (strs.length == 0) {
    return "";
StringBuffer sbuf = new StringBuffer();
sbuf.append(strs[0]);
for (int idx = 1; idx < strs.length; idx++) {
    sbuf.append(",");
    sbuf.append(strs[idx]);
...
StringarrayToString(String[] strs, String separator)
array To String
if (null == separator || "".equalsIgnoreCase(separator)) {
    separator = DEFAULT_SEPARATOR;
if (strs.length == 0) {
    return "";
StringBuffer sbuf = new StringBuffer();
sbuf.append(strs[0]);
...
StringarrayToString(String[] theArray)
array To String
String myString = "";
for (int i = 0; i < theArray.length; i++) {
    myString += theArray[i] + ",";
myString = myString.substring(0, myString.length() - 1);
return myString;
StringArrayToString(String[] values)
Array To String
return ArrayToString(values, ',');
StringarrayToString(String[] values)
Converts a string array to a string.
StringBuffer buffer = new StringBuffer();
if (values == null) {
    buffer.append("null");
} else {
    buffer.append("{");
    for (int i = 0; i < values.length; i++) {
        buffer.append(values[i]);
        if (i < values.length - 1) {
...
StringarrayToString(String[] values)
array To String
StringBuilder paramsString = new StringBuilder();
for (int i = 0; i < values.length; i++) {
    if (i == 0) {
        paramsString.append(values[i]);
    } else {
        paramsString.append(",");
        paramsString.append(values[i]);
return paramsString.toString();
StringarrayToString(String[] values)
array To String
if (values == null || values.length == 0)
    return "";
StringBuilder sb = new StringBuilder(values.length);
for (int i = 0; i < values.length; i++) {
    if (i > 0)
        sb.append(',');
    sb.append(values[i]);
return sb.toString();
StringarrayToString(String[] values)
Converts String array to a string representation of List.
StringBuilder valueStr = new StringBuilder();
if ((null == values) || (values.length == 0)) {
    valueStr.append("[]");
} else {
    valueStr.append("[");
    for (String value : values) {
        valueStr.append("'").append(value).append("',");
    valueStr.deleteCharAt(valueStr.lastIndexOf(","));
    valueStr.append("]");
return valueStr.toString();
StringarrayToString(String[] values)
A method to take an array of values and return them in a comma delimited list
return java.util.Arrays.toString(values).replaceAll("[\\]\\[]", "");