Java Array to Delimited String arrayToDelimitedString(Object[] arr, String delim)

Here you can find the source of arrayToDelimitedString(Object[] arr, String delim)

Description

array To Delimited String

License

Open Source License

Parameter

Parameter Description
Object []

Return

String

Declaration


public static String arrayToDelimitedString(Object[] arr, String delim) 

Method Source Code

//package com.java2s;

public class Main {

    public static String arrayToDelimitedString(Object[] arr, String delim) {

        if (arr == null || arr.length == 0) {
            return "";
        }/*from  w  w w .  j  a  va 2  s .  co  m*/
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < arr.length; i++) {
            if (i > 0) {
                sb.append(delim);
            }
            sb.append('\'');
            sb.append(arr[i]);
            sb.append('\'');
        }
        return sb.toString();
    }
}

Related

  1. arrayToCommaSeparatedString(int[] array)
  2. arrayToCommaString(int[] array)
  3. arrayToCommaString(int[] array)
  4. arrayToDelimitedString(Object[] arr, String delim)
  5. arrayToDelimitedString(Object[] arr, String delim)
  6. arrayToDelimitedString(String[] values, String delimiter)
  7. arrayToDelimitedString(T[] array, String left, String delimiter, String right)
  8. arrayToReadableString(String[] array)
  9. arrayToTabSeparatedString( final String[] values)