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(int[] array)
Show tasks with standard format
if (array.length == 0) {
    return ""; 
String msg = ""; 
int preTask = array[0];
msg += preTask;
boolean isContinue = false;
for (int i = 1; i < array.length; i++) {
...
StringarrayToString(int[] array)
array To String
StringBuilder sb = new StringBuilder();
for (int i = array.length - 1; i >= 0; i--) {
    sb.append(array[i]);
return sb.toString();
StringarrayToString(int[] ary)
array To String
if (ary == null || ary.length == 0)
    return "";
int m = ary.length - 1;
StringBuilder sb = new StringBuilder();
for (int i = 0;; i++) {
    sb.append(ary[i]);
    if (i == m)
        return sb.toString();
...
StringarrayToString(int[] c, String separator)
array To String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < c.length; i++) {
    if (i > 0) {
        sb.append(separator);
    sb.append(c[i]);
return sb.toString();
...
StringarrayToString(int[] s)
Translate an array of int-s specifying throw height into a String that uses the normal siteswap notation.
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length; i++) {
    try {
        sb.append(intToChar(s[i]));
    } catch (Exception e) {
        return null;
return sb.toString();
StringarrayToString(int[] subset)
array To String
StringBuilder sb = new StringBuilder("[");
for (int i = 0; i < subset.length - 1; ++i)
    sb.append(subset[i] + ",");
sb.append(subset[subset.length - 1] + "]");
return sb.toString();
StringarrayToString(int[][] array)
array To String
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int i = 0; i < array.length; i++) {
    for (int j = 0; j < array[0].length; j++) {
        out.write(array[i][j]);
return new String(out.toByteArray());
StringarrayToString(Object arbitraryArray)
Converts an array (either Object[] or of a primitive type) to a String containing it's elements in square brackets.
Class<?> compType = arbitraryArray.getClass().getComponentType();
if (compType == null)
    throw new IllegalArgumentException();
if (compType.isPrimitive()) {
    if (compType == Integer.TYPE)
        return Arrays.toString((int[]) arbitraryArray);
    else if (compType == Long.TYPE)
        return Arrays.toString((long[]) arbitraryArray);
...
StringarrayToString(Object array)
Convenience method.
if (array == null)
    return "null";
else
    return arrayToString((Object[]) array);
StringarrayToString(Object array)
Returns a string representation of the given array.
if (array == null) {
    throw new NullPointerException();
if (array instanceof int[]) {
    return Arrays.toString((int[]) array);
if (array instanceof long[]) {
    return Arrays.toString((long[]) array);
...