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

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

Description

Convert String[] to String

License

Open Source License

Parameter

Parameter Description
str - input String [] for converting
separator - separator. used while converting input String [] to String

Return

Convert String[] to String

Declaration

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

Method Source Code

//package com.java2s;
/**/*from   w w  w .  j  ava  2s  .  c om*/
 * *************************************************************************
 * Copyright (C) 2014 GGA Software Services LLC
 * <p>
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 3 as published by the Free Software
 * Foundation.
 * <p>
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 * <p>
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 * *************************************************************************
 */

public class Main {
    /**
     * Convert String[] to String
     *
     * @param str - input String [] for converting
     * @param separator - separator. used while converting input String [] to String
     * @return Convert String[] to String
     */
    public static String arrayToString(String[] str, String separator) {
        StringBuilder result = new StringBuilder();

        if (str.length > 0) {
            result.append(str[0]);
            for (int i = 1; i < str.length; i++) {
                result.append(separator);
                result.append(str[i]);
            }
        }
        return result.toString();
    }
}

Related

  1. arrayToString(String[] lines, String separator)
  2. arrayToString(String[] ngram)
  3. arrayToString(String[] object)
  4. arrayToString(String[] s, String delim)
  5. arrayToString(String[] str, char sep)
  6. arrayToString(String[] stringArray)
  7. arrayToString(String[] stringArray)
  8. arrayToString(String[] strings)
  9. arrayToString(String[] strs)