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

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

Description

Converts string array to single string separating fields with specified separator.

License

Open Source License

Parameter

Parameter Description
array a parameter
separator a parameter

Declaration

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

Method Source Code

//package com.java2s;

public class Main {
    /**//from w  ww .  j a  v a  2s . c o m
     * Converts string array to single string separating fields with specified
     * separator.
     * 
     * @param array
     * @param separator
     * @return
     */
    public static String arrayToString(String[] array, String separator) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++) {
            if (i != 0) {
                builder.append(separator);
            }
            builder.append(array[i]);
        }

        return builder.toString();
    }
}

Related

  1. arrayToString(String[] array)
  2. arrayToString(String[] array)
  3. arrayToString(String[] array, int start, String delimiter)
  4. arrayToString(String[] array, String delim, boolean quotes)
  5. arrayToString(String[] array, String separator)
  6. arrayToString(String[] array, String separators)
  7. arrayToString(String[] arrayString, String splitStr)
  8. arrayToString(String[] input)
  9. arrayToString(String[] lengthsAndDelimiters)