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

Stringarray2displaystr(Object[] datas)
arraydisplaystr
if (datas == null || datas.length == 0) {
    return "[]";
StringBuffer r = new StringBuffer();
r.append("[");
for (int i = 0; i < datas.length && i < 11; i++) {
    r.append(datas[i]).append(',');
r.setCharAt(r.length() - 1, ']');
return r.toString();
Stringarray2String(double[] array)
convert a double[] to a String "x[0],x[1],..."
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; i++) {
    sb.append(String.valueOf(array[i]) + " ");
return sb.toString();
Stringarray2String(E[] array)
array String
return array2String(array, 0, array.length);
Stringarray2string(final T[] array, final int top)
Converts the array of objects to string, where each array element is separated by comma.
StringBuffer buf = new StringBuffer();
for (int i = 0; i < (array.length > top ? top : array.length); i++) {
    if (i > 0) {
        buf.append(", ");
    buf.append(array[i]);
if (top < array.length) {
...
Stringarray2string(int[] _a)

Creates a string from an array of integer

String toRet = "";
for (int i = 0; i < _a.length - 1; ++i) {
    toRet += Double.toString(_a[i]) + ", ";
toRet += _a[_a.length - 1];
return toRet;
Stringarray2String(int[] paramArrayOfInt)
array String
StringBuffer localStringBuffer = new StringBuffer();
for (int i = 0;; i++) {
    if (i >= paramArrayOfInt.length)
        return localStringBuffer.toString();
    localStringBuffer.append(paramArrayOfInt[i] + ";");
Stringarray2String(long[] array)
array String
StringBuffer ret = new StringBuffer("[");
if (array != null) {
    for (int i = 0; i < array.length; i++)
        ret.append(array[i]).append(" ");
ret.append(']');
return ret.toString();
Stringarray2String(long[] array)
array String
StringBuilder ret = new StringBuilder("[");
if (array != null) {
    for (int i = 0; i < array.length; i++)
        ret.append(array[i]).append(" ");
ret.append(']');
return ret.toString();
Stringarray2String(Object[] a, int size)
array String
if (a == null)
    return "null";
int iMax = size - 1;
if (iMax == -1)
    return "[]";
StringBuilder b = new StringBuilder();
b.append('[');
for (int i = 0;; i++) {
...
Stringarray2string(Object[] array)
arraystring
StringBuffer sb = new StringBuffer("");
for (int i = 0; i < array.length - 1; i++) {
    sb.append(array[i].toString());
    sb.append(", ");
if (array.length > 0)
    sb.append(array[array.length - 1]);
return sb.toString();
...