Java Utililty Methods Integer Array to String

List of utility methods to do Integer Array to String

Description

The list of methods to do Integer Array to String are organized into topic(s).

Method

StringintArrayAsString(int[] a)
int Array As String
if (null == a)
    return null;
int len = a.length;
StringBuffer pcs = new StringBuffer(0 < len ? "[" + a[0] : "[");
for (int i = 1; i < len; i++)
    pcs.append(", " + a[i]);
pcs.append(']');
return pcs.toString();
...
StringintArrayToString(final int... ints)
Converts an integer array to a string with only 16-bit charaters
int len = ints.length;
for (final int i : ints)
    if (i > 0xFFFF)
        len++;
    else if (i > 0x10FFFF)
        throw new RuntimeException("Be serious, there is no character above plane 16.");
final char[] chars = new char[len];
int ptr = 0;
...
StringintArrayToString(int vals[])
Convert an int array to a string
StringBuilder buf = new StringBuilder();
for (int i = 0; i < vals.length; ++i) {
    buf.append((char) vals[i]);
return buf.toString();
StringintArraytoString(int[] a)
int Arrayto String
if (a == null)
    return "";
int iMax = a.length - 1;
if (iMax == -1)
    return "";
StringBuilder b = new StringBuilder();
for (int i = 0;; i++) {
    b.append(a[i]);
...
StringintArrayToString(int[] a)
int Array To String
StringBuilder retval = new StringBuilder();
for (int val : a) {
    retval.append(String.format("%d ", val));
return retval.toString();
StringintArrayToString(int[] a, String separator)
int Array To String
int len = a.length;
if (len == 0) {
    return "[]";
StringBuilder builder = new StringBuilder();
builder.append("[ ").append(a[0]);
if (len > 1) {
    for (int i = 1; i < a.length; i++) {
...
StringintArrayToString(int[] arr)
Present an int array as a comma separated list string
String s = "";
if (arr != null)
    for (int i = 0; i < arr.length - 1; i++)
        s += arr[i] + ",";
if (arr.length > 0)
    s += arr[arr.length - 1];
return s;
StringintArrayToString(int[] array)
Creates a string representation of the given array of type int[] (this representation can be parsed using the method parseIntegerArray).
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int a : array) {
    sb.append(a).append(", ");
if (sb.lastIndexOf(", ") != -1)
    sb.delete(sb.lastIndexOf(", "), sb.length());
sb.append("]");
...
StringintArrayToString(int[] array, boolean whiteSpaceSeperator)
int Array To String
if (null == array)
    return null;
StringBuffer s = new StringBuffer();
for (int i = 0; i < array.length; i++) {
    s.append(array[i]);
    if (whiteSpaceSeperator)
        s.append(' ');
return s.toString();
StringintArrayToString(int[] ia)
Utility to convert an int[] to a String.
if (ia == null) {
    return "null";
StringBuilder sb = new StringBuilder("[");
for (int i = 0; i < ia.length; ++i) {
    if (i > 0) {
        sb.append(", ");
    sb.append(ia[i]);
sb.append(']');
return sb.toString();