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[] args, String delimiter)
array To String
StringBuilder b = new StringBuilder();
for (String arg : args) {
    b.append(arg);
    b.append(delimiter);
return b.substring(0, b.length() - delimiter.length());
StringarrayToString(String[] arr)
Helper method serlializing an array as string using "/" as separator.
if (arr != null && arr.length > 0) {
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < arr.length; i++) {
        builder.append(arr[i]);
        if (i < arr.length - 1) {
            builder.append("/");
    return builder.toString();
} else {
    return "<no values specified>";
StringarrayToString(String[] arr, String expr)
array To String
String strInfo = "";
if (arr != null && arr.length > 0) {
    StringBuffer sf = new StringBuffer();
    for (String str : arr) {
        sf.append(str);
        sf.append(expr);
    strInfo = sf.substring(0, sf.length() - 1);
...
StringarrayToString(String[] array)
Convert an Array to a comma seperated String
String output = "";
for (int i = 0; i < array.length; i++) {
    if (output.equals("")) {
        output = output + array[i];
    } else {
        output = output + ", " + array[i];
return output;
StringarrayToString(String[] array)
array To String
String toReturn = null;
if (null != array) {
    toReturn = "";
    for (int i = 0; i < array.length; i++) {
        toReturn += array[i] + ",\n";
} else {
    System.out.println("arrayToString(null)!");
...
StringarrayToString(String[] array)
Returns String representing array of Strings.
return Arrays.toString(array);
StringarrayToString(String[] array)
array To String
StringBuilder builder = new StringBuilder();
builder.append("{");
int valCount = 0;
for (String val : array) {
    if (valCount++ > 0) {
        builder.append(", ");
    builder.append(val);
...
StringarrayToString(String[] array)
array To String
if (array.length == 0) {
    return "[]";
StringBuilder str = new StringBuilder();
str.append("[").append(array[0]);
for (int i = 1; i < array.length; i++) {
    str.append(" ").append(array[i]);
str.append("]");
return str.toString();
StringarrayToString(String[] array)
array To String
if ((array == null) || (array.length == 0)) {
    return "";
StringBuilder sb = new StringBuilder();
for (String s : array) {
    sb.append(';');
    sb.append(s);
return sb.substring(1);
StringarrayToString(String[] array)
Convert array to string of comma separated values.
if (array != null && array.length > 0) {
    return Arrays.deepToString(array).replace(" ", "").replace("[", "").replace("]", "");
return "";