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

StringtoString(Object[] array)
to String
return toString(array, ", ");
StringtoString(Object[] array)
Create a string representation of the given array
StringBuffer buf = new StringBuffer();
buf.append(": ");
for (int i = 0; i < array.length; i++) {
    buf.append("[");
    buf.append(i);
    buf.append("]: ");
    buf.append((array[i] == null) ? "null" : array[i]);
    buf.append(" ");
...
StringtoString(Object[] objects)
to String
return join(", ", objects);
StringtoString(String arrayName, T[] targets)
Constructs a String representation of an array and its values.
final int n = targets.length;
StringBuilder sb = new StringBuilder();
sb.append(arrayName).append(" { ");
for (int i = 0; i < n; i++) {
    sb.append(targets[i].toString());
    if (i + 1 < n)
        sb.append(",");
    sb.append(" ");
...
StringtoString(String[] args, char color1, char color2)
to String
StringBuilder stringBuilder = new StringBuilder();
if (args.length > 1) {
    for (int iii = 0; iii < args.length - 1; iii++) {
        stringBuilder.append("\247");
        stringBuilder.append(color1);
        stringBuilder.append(args[iii]);
        stringBuilder.append("\247");
        stringBuilder.append(color2);
...
StringtoString(String[] arguments)
Provides a debug helper for printing out all arguments of a process for error tracking.
StringBuffer call = new StringBuffer();
for (int j = 0; j < arguments.length; j++) {
    String arg = arguments[j];
    if (arg.indexOf(' ') != -1) {
        call.append('"').append(arg).append('"');
    } else {
        call.append(arg);
    call.append(' ');
return call.toString();
StringtoString(String[] array, String delimiter)
Converts an array of string to a string concatenation separated by the given delimiter.
if (array == null || array.length == 0) {
    return null;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; i++) {
    sb.append(array[i]);
    if (i != array.length - 1) {
        sb.append(delimiter);
...
StringtoString(String[] line)
to String
if (line == null)
    return "";
StringBuilder str = new StringBuilder(512);
for (int i = 0; i < line.length; ++i) {
    if (i != 0)
        str.append(',');
    str.append(line[i]);
if (str.length() > 0)
    str.append("\n");
return str.toString();
StringtoString(String[] paramNames, Object[] params)
Converts the parameters to string.
StringBuffer sb = new StringBuffer(" Input parameters: {");
if (params != null) {
    for (int i = 0; i < params.length; i++) {
        if (i > 0) {
            sb.append(", ");
        sb.append(paramNames[i]).append(":").append(toString(params[i]));
sb.append("}.");
return sb.toString();
StringtoString(T[] array)
to String
return toString(Arrays.asList(array));