Java Utililty Methods Array to Delimited String

List of utility methods to do Array to Delimited String

Description

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

Method

StringarrayAsCommaSeperatedList(String... items)
array As Comma Seperated List
String result = items[0];
for (int i = 1; i < items.length; i++) {
    result += "," + items[i];
return result;
StringarrayAsString(final int[] _intArray)
Utility method (debug/test): Trivial helper function for quick trace output.
String strArray = "";
for (int i = 0; i < _intArray.length; i++)
    strArray += _intArray[i] + " ";
return strArray;
StringarrayToCommaDelimitedString(Object[] arr)
Convenience method to return a String array as a CSV String.
return arrayToDelimitedString(arr, ",");
StringarrayToCommaDelimitedString(Object[] arr)
array To Comma Delimited String
return arrayToDelimitedString(arr, ",");
StringarrayToCommaDelimitedString(Object[] strings)
Turns this string array in one comma-delimited string.
if (strings == null) {
    return "";
StringBuilder builder = new StringBuilder();
for (int i = 0; i < strings.length; i++) {
    if (i > 0) {
        builder.append(",");
    builder.append(String.valueOf(strings[i]));
return builder.toString();
StringarrayToCommaSeparatedString(int[] array)
array To Comma Separated String
if (array == null) {
    return null;
StringBuffer result = new StringBuffer();
for (int i = 0; i < array.length; i++) {
    result.append(array[i] + (i == array.length - 1 ? "" : ", "));
return result.toString();
...
StringarrayToCommaString(int[] array)
array To Comma String
StringBuffer sb = new StringBuffer();
for (int i = array.length - 1; i >= 0; i--) {
    if (array[i] == 0) {
        continue;
    sb.append(array[i]);
    sb.append(i == 0 ? "" : ",");
return sb.toString();
StringarrayToCommaString(int[] array)
array To Comma String
StringBuffer sb = new StringBuffer();
for (int i = array.length - 1; i >= 0; i--) {
    if (array[i] == 0) {
        continue;
    sb.append(array[i]);
    sb.append(i == 0 ? "" : ",");
return sb.toString();
StringarrayToDelimitedString(Object[] arr, String delim)
array To Delimited String
if (arr == null || arr.length == 0) {
    return "";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < arr.length; i++) {
    if (i > 0) {
        sb.append(delim);
    sb.append('\'');
    sb.append(arr[i]);
    sb.append('\'');
return sb.toString();
StringarrayToDelimitedString(Object[] arr, String delim)
Convenience method to return a String array as a delimited (e.g.
if (arr == null)
    return "null";
else {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < arr.length; i++) {
        if (i > 0)
            sb.append(delim);
        sb.append(arr[i]);
...