Java Array Join arrayJoin(String[] arr, String joinStr)

Here you can find the source of arrayJoin(String[] arr, String joinStr)

Description

array Join

License

Apache License

Declaration

public static String arrayJoin(String[] arr, String joinStr) 

Method Source Code

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

public class Main {

    public static String arrayJoin(String[] arr, String joinStr) {
        if (arr == null || arr.length == 0)
            return null;
        if (joinStr == null)
            joinStr = "";
        StringBuffer buf = new StringBuffer();
        for (String str : arr)
            buf.append(str).append(joinStr);
        return buf.substring(0, buf.length() - joinStr.length());
    }/*  w w w  .  ja  v  a 2s  .c  o m*/
}

Related

  1. arrayJoin(int[] a, int[] b)
  2. arrayJoin(String[] array, char with)
  3. arrayJoinToString(Object[] array, CharSequence delim)
  4. join(byte[]... bs)
  5. join(char sep, Object[] array)