Java Array to String arrayToString(T[] array)

Here you can find the source of arrayToString(T[] array)

Description

array To String

License

Apache License

Declaration

public static <T> String arrayToString(T[] array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static <T> String arrayToString(T[] array) {
        return arrayToDelimitedString(array, 0, array.length, "", "", "");
    }/*from  www . ja  v a2  s  . c om*/

    public static <T> String arrayToDelimitedString(T[] array, String left,
            String delimiter, String right) {
        return arrayToDelimitedString(array, 0, array.length, left,
                delimiter, right);
    }

    public static <T> String arrayToDelimitedString(T[] array, int offset,
            int length, String delimiter) {
        return arrayToDelimitedString(array, offset, length, "", delimiter,
                "");
    }

    public static <T> String arrayToDelimitedString(T[] array,
            String delimiter) {
        return arrayToDelimitedString(array, 0, array.length, "",
                delimiter, "");
    }

    public static <T> String arrayToDelimitedString(T[] array, int offset,
            int length, String left, String delimiter, String right) {
        StringBuilder buf = new StringBuilder();
        for (int i = offset; i < offset + length - 1; i++) {
            buf.append(left).append(array[i]).append(right)
                    .append(delimiter);
        }
        if (length > 0)
            buf.append(left).append(array[offset + length - 1])
                    .append(right);
        return buf.toString();
    }
}

Related

  1. arrayToString(T[] array)
  2. arrayToString(T[] array)
  3. arrayToString(T[] array)
  4. arrayToString(T[] array)
  5. arrayToString(T[] array)
  6. arrayToString(T[] array, CharSequence start, CharSequence end)
  7. arrayToString(T[] items, String delimiter)
  8. arrayToString2D(String title, String innerTitle, double[][] vect)
  9. arrayToStringArray(boolean[] values)