Java CSV String Create csv(String separator, String... elements)

Here you can find the source of csv(String separator, String... elements)

Description

csv

License

Apache License

Declaration

public static String csv(String separator, String... elements) 

Method Source Code

//package com.java2s;
/*//from w w  w. ja v a  2s .  co m
 *  Copyright (c) 2012-2014 RONDHUIT Co.,Ltd.
 *  
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   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 csv(String separator, String... elements) {
        if (elements.length == 0)
            return null;

        StringBuilder sb = new StringBuilder(elements[0]);
        for (int i = 1; i < elements.length; i++) {
            sb.append(separator).append(elements[i]);
        }
        return sb.toString();
    }
}

Related

  1. getCSV(Collection coll)
  2. getCSV(Collection values)
  3. getCsv(Collection collection)
  4. getCSVPhrase(Collection objects)