Java Array to String arrayToStr(Object[] arr, char split)

Here you can find the source of arrayToStr(Object[] arr, char split)

Description

e.g: String[] result={"TYHR0001","TYHR0002"}; split=","; return: str="TYHR0001,TYHR0002";

License

Open Source License

Parameter

Parameter Description
Object []
split a parameter

Return

String

Declaration

public static String arrayToStr(Object[] arr, char split) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   w ww . ja v a  2 s .  c o m
     * e.g: String[] result={"TYHR0001","TYHR0002"}; split=","; return:
     * str="TYHR0001,TYHR0002";
     * 
     * @param Object
     *            []
     * @param split
     * @return String
     */
    public static String arrayToStr(Object[] arr, char split) {
        if (arr == null || arr.length == 0) {
            return null;
        }
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < arr.length; i++) {
            if (i > 0) {
                sb.append(split);
            }
            sb.append(arr[i]);

        }
        return sb.toString();
    }
}

Related

  1. array2String(T... array)
  2. array2String(T[] array, String splitFlag, boolean useBracket)
  3. arrayContent(int[] ar)
  4. arrayToRLEString(int[] a)
  5. arrayToRLEString(short[] a)
  6. arrayToStr(Object[] arr, char split)
  7. arrayToStr(String[] o)
  8. ArrayToStr(String[] strArr, String seperatedBy)
  9. arrayToStr(String[] strArray)