Java Array to String array2String(T[] array, String splitFlag, boolean useBracket)

Here you can find the source of array2String(T[] array, String splitFlag, boolean useBracket)

Description

array String

License

Apache License

Declaration

public static <T> String array2String(T[] array, String splitFlag,
        boolean useBracket) 

Method Source Code

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

public class Main {

    public static <T> String array2String(T[] array, String splitFlag,
            boolean useBracket) {
        if (array != null && array.length == 0) {
            return null;
        }//  w  w  w  . java2  s .  co m

        StringBuilder sb = new StringBuilder();
        for (T t : array) {
            sb.append(t.toString() + splitFlag);
        }
        int sbLen = sb.length();
        sb.delete(sbLen - 2, sbLen);
        if (useBracket) {
            sb.insert(0, '[');
            sb.append(']');
        }

        return sb.toString();
    }
}

Related

  1. array2String(String[] array)
  2. array2String(String[] category)
  3. array2String(String[] p, String spliter)
  4. Array2String(String[] values)
  5. array2String(T... array)
  6. arrayContent(int[] ar)
  7. arrayToRLEString(int[] a)
  8. arrayToRLEString(short[] a)
  9. arrayToStr(Object[] arr, char split)