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

Stringarray2String(Object[] objs)
array String
StringBuffer buffer = new StringBuffer();
if (objs != null) {
    for (int i = 0; i < objs.length; i++) {
        buffer.append(objs[i]).append(",");
buffer.deleteCharAt(buffer.length() - 1);
return buffer.toString();
...
Stringarray2String(String[] array)
array String
if (array == null || array.length <= 0)
    return null;
StringBuilder builder = new StringBuilder();
for (int i = 0; i < array.length - 1; i++) {
    builder.append(array[i]);
    builder.append(SPLIT_SYMBOL);
builder.append(array[array.length - 1]);
...
Stringarray2String(String[] array)
array String
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < array.length; i++) {
    buffer.append(",").append(array[i]);
return buffer.toString().replaceFirst(",", "");
Stringarray2String(String[] category)
array String
StringBuilder sb = new StringBuilder();
String delim = "";
if (category.length >= 1) {
    for (int i = 0; i < category.length; i++) {
        sb.append(delim).append(category[i]);
        delim = "#";
return sb.toString();
Stringarray2String(String[] p, String spliter)
array String
if (p == null)
    return null;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < p.length; i++) {
    if (i == 0)
        sb.append(p[i]);
    else
        sb.append(spliter).append(p[i]);
...
StringArray2String(String[] values)
Array String
String result = "";
if (values == null) {
    return result;
int len = values.length;
for (int i = 0; i < len; i++) {
    result += values[i] + ",";
if (result.endsWith(",")) {
    result = result.substring(result.length() - 1);
return result;
Stringarray2String(T... array)
array String
int len = array.length;
if (len == 0) {
    return "";
StringBuilder sb = new StringBuilder();
sb.append("[").append(array[0]);
for (int i = 1; i < array.length; i++) {
    sb.append(",").append(array[i]);
...
Stringarray2String(T[] array, String splitFlag, boolean useBracket)
array String
if (array != null && array.length == 0) {
    return null;
StringBuilder sb = new StringBuilder();
for (T t : array) {
    sb.append(t.toString() + splitFlag);
int sbLen = sb.length();
...
StringarrayContent(int[] ar)
array Content
String str = "";
for (int i = 0; i < ar.length; i++) {
    str += ar[i] + ",";
return str;
StringarrayToRLEString(int[] a)
Construct a string representing an int array.
StringBuffer buffer = new StringBuffer();
appendInt(buffer, a.length);
int runValue = a[0];
int runLength = 1;
for (int i = 1; i < a.length; ++i) {
    int s = a[i];
    if (s == runValue && runLength < 0xFFFF) {
        ++runLength;
...