Java Array to String convertArrayToString(String[] array, String separator)

Here you can find the source of convertArrayToString(String[] array, String separator)

Description

* This method convert array to a string which is seperated by a seprator passed in argument.

License

LGPL

Parameter

Parameter Description
array array which is to be converted into string
separator separator between two element of array.

Return

String string data

Declaration

public static String convertArrayToString(String[] array, String separator) 

Method Source Code

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

public class Main {
    /**//from www. java2 s.  com
     * *
     * This method convert array to a string which is seperated by a seprator passed in argument.
     *
     * @param array array which is to be converted into string
     * @param separator separator between two element of array.
     * @return String string data
     */
    public static String convertArrayToString(String[] array, String separator) {
        StringBuilder builder = new StringBuilder();
        for (String string : array) {
            if (string != null) {
                builder.append(separator).append(string);
            }
        }
        return builder.substring(separator.length());
    }
}

Related

  1. convertArrayToString(Object[] ig, int count)
  2. convertArrayToString(Object[] objArr)
  3. convertArrayToString(String[] array)
  4. convertArrayToString(String[] array, char seperator)
  5. convertArrayToString(String[] array, String separator)
  6. convertArrayToString(String[] fields, String delimiter)
  7. convertArrayToString(String[] idArray)
  8. convertArrayToString(String[] strArray)
  9. convertByteToString(byte[] objectGuid)