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(int[] v, char delim)
Return a string representation of an integer array.
if (v == null)
    return "";
StringBuilder strbuf = new StringBuilder();
for (int i = 0; i < v.length; i++) {
    if (i > 0)
        strbuf.append(delim);
    strbuf.append(v[i]);
return strbuf.toString();
String[]toString(long[] dom)
to String
String[] result = new String[dom.length];
for (int i = 0; i < dom.length; i++)
    result[i] = String.valueOf(dom[i]);
return result;
StringtoString(Map arg)
to String
String str = null;
if (arg != null) {
    StringBuffer sb = new StringBuffer();
    sb.append("{");
    Set<Entry<String, String[]>> entries = arg.entrySet();
    for (Entry<String, String[]> entry : entries) {
        String key = entry.getKey();
        String val = Arrays.toString(entry.getValue());
...
StringtoString(Object array)
to String
if (array == null) {
    return null;
Class<?> type = array.getClass();
if (type.isArray()) {
    if (type.getComponentType().isPrimitive()) {
        if (type == byte[].class) {
            byte[] valueArray = (byte[]) array;
...
StringtoString(Object array)
Constructs a string representation for the given array that describes its contents (as opposed to the default Object#toString() version that arrays inherit).
Class<?> arrayType = array.getClass();
if (!arrayType.isArray()) {
    throw new IllegalArgumentException("specified object is not an array");
Class<?> componentType = arrayType.getComponentType();
if (componentType.isPrimitive()) {
    if (componentType == boolean.class) {
        return Arrays.toString((boolean[]) array);
...
StringtoString(Object array)

Outputs an array as a String, treating null as an empty array.

return toString(array, "{}");
StringtoString(Object array[])
to String
return toString(array, ",");
StringtoString(Object[] a)
Returns a string representation of the contents of the specified array.
if (a == null)
    return "null";
if (a.length == 0)
    return "[]";
StringBuffer buf = new StringBuffer();
buf.append('[').append(a[0]);
for (int i = 1; i < a.length; i++) {
    buf.append(", ").append(a[i]);
...
StringtoString(Object[] array)
Returns the specified array as a comma-delimited (',') string.
return toDelimitedString(array, ",");
StringtoString(Object[] array)
Convert the given array to String.
return Arrays.toString(array);