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(Object[] arr)
array To String
StringBuffer buf = new StringBuffer();
buf.append('[');
for (int i = 0; i < arr.length; i++) {
    if (i != 0)
        buf.append(", ");
    buf.append(arr[i].toString());
buf.append(']');
...
StringarrayToString(Object[] arr)
Converts the specified array into a string by appending all its elements separated by a semicolon.
StringBuffer buf = new StringBuffer();
for (int i = 0; i < arr.length; i++) {
    buf.append(arr[i]);
    buf.append("; ");
if (arr.length > 0)
    buf.setLength(buf.length() - 2); 
return buf.toString();
...
StringarrayToString(Object[] arr, String split)
array To String
if (isEmpty(split)) {
    split = ", ";
StringBuilder buf = new StringBuilder();
if (arr != null && arr.length > 0) {
    buf.append(arr[0]);
    for (int i = 1; i < arr.length; i++) {
        buf.append(split).append(arr[i]);
...
StringarrayToString(Object[] array)
Convert array contents to string.
String result = "";
if ((array != null) && (array.length > 0)) {
    for (int i = 0; i < array.length; i++) {
        Object value = array[i];
        if (i > 0)
            result = result + ", ";
        if (value == null) {
            result = result + "null";
...
StringarrayToString(Object[] array)
array To String
if (null != array) {
    if (array.length == 1) {
        return array[0].toString();
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < array.length; i++) {
        if (i > 0) {
            builder.append(",");
...
StringarrayToString(Object[] array)
array To String
return arrayToString(array, DEFAULT_SEPARATOR);
StringarrayToString(Object[] array)
Convert an array object to string, the component of the array should have a public method toString()
if (null == array)
    return null;
StringBuffer s = new StringBuffer();
for (int i = 0; i < array.length; i++)
    s.append(array[i].toString());
return s.toString();
StringarrayToString(Object[] array)
Converts the specified array to a string.
if (array == null) {
    return NULL_STR;
if (array.length == 0) {
    return "[]";
} else if (array.length == 1) {
    return "[" + array[0] + "]";
} else {
...
StringarrayToString(Object[] array)
Returns a comma-delimited string representation of the specified array, with []s.
return arrayToString(array, ", ", -1);
StringarrayToString(Object[] array)
Print out an array as a String
return arrayToString(array, ',');