Java String Implode implodeStringArray(String tokens[], String separator)

Here you can find the source of implodeStringArray(String tokens[], String separator)

Description

implode String Array

License

Educational Community License

Declaration

public static String implodeStringArray(String tokens[],
            String separator) 

Method Source Code

//package com.java2s;
/**//from w  w w  .jav a 2 s . co  m
 *  This document is a part of the source code and related artifacts
 *  for CollectionSpace, an open source collections management system
 *  for museums and related institutions:

 *  http://www.collectionspace.org
 *  http://wiki.collectionspace.org

 *  Copyright 2009 University of California at Berkeley

 *  Licensed under the Educational Community License (ECL), Version 2.0.
 *  You may not use this file except in compliance with this License.

 *  You may obtain a copy of the ECL 2.0 License at

 *  https://source.collectionspace.org/collection-space/LICENSE.txt

 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the license.
 */

public class Main {
    public static String implodeStringArray(String tokens[],
            String separator) {
        if (tokens.length == 0) {
            return "";
        } else {
            StringBuffer sb = new StringBuffer();
            sb.append(tokens[0]);
            for (int i = 1; i < tokens.length; i++) {
                sb.append(separator);
                sb.append(tokens[i]);
            }
            return sb.toString();
        }
    }
}

Related

  1. implode(String[] stringsArr, String glue)
  2. implode(StringBuilder sbuf, Object[] data, String separator)
  3. implode(T[] array, String delim)
  4. implodeParams(Object[] params)
  5. implodeString(String[] strings, String seperator)
  6. implodeStrings(String[] strings)