Here you can find the source of arrayToString(String[] str, String separator)
Parameter | Description |
---|---|
str | - input String [] for converting |
separator | - separator. used while converting input String [] to String |
public static String arrayToString(String[] str, String separator)
//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(); } }