Java String to convertStringArrayToString(String[] a_asStrings, String a_sDelim)

Here you can find the source of convertStringArrayToString(String[] a_asStrings, String a_sDelim)

Description

Takes an array of Strings and turns them in to a comma delimited list of strings in a string.

License

Open Source License

Parameter

Parameter Description
String a_sDelim - the string delimiter to use

Return

String[] - the string containing the list of strings

Declaration

public static String convertStringArrayToString(String[] a_asStrings, String a_sDelim)

    

Method Source Code

//package com.java2s;

public class Main {
    /**/*from ww w.ja v  a 2s  . com*/
     * Takes an array of Strings and turns them in to a comma delimited list of
     * strings in a string.
     *
     * @param String[] a_asStrings - the array of strings to make the string from
     * @param String a_sDelim - the string delimiter to use
     * @return String[] - the string containing the list of strings
     *
     */
    public static String convertStringArrayToString(String[] a_asStrings, String a_sDelim)
    /*
    ------------------------------------------------------------------------
     d1   20-Oct-2003   Chris Preager    Created from Img Mangr
    ------------------------------------------------------------------------
     */
    {
        StringBuffer sb = new StringBuffer("");

        if ((a_asStrings != null) && (a_asStrings.length > 0)) {
            sb.append(a_asStrings[0]);

            if (a_asStrings.length > 1) {
                for (int i = 1; i < a_asStrings.length; i++) {
                    sb.append(a_sDelim + a_asStrings[i]);
                }
            }
        }

        return (sb.toString());
    }
}

Related

  1. convertString(String strValue)
  2. convertString(String value, Class type)
  3. convertString2Bytes(String str)
  4. convertString2GSonString(String str)
  5. convertStringArrayToFloatArray(String[] num)
  6. convertStringArrayToString(String[] value, String separator)
  7. convertStringFormat(String property)
  8. convertStringsToTextSet(String[] values)
  9. convertStringToArray(String str)