Java Collection Join join(Collection in, String joinS)

Here you can find the source of join(Collection in, String joinS)

Description

join

License

Open Source License

Declaration

public static String join(Collection<String> in, String joinS) 

Method Source Code

//package com.java2s;
/*************************************************************************
 * Copyright 2012 Regents of the University of Michigan 
 * /*  w  w w  . j a v a  2s. c o  m*/
 * NCIBI - The National Center for Integrative Biomedical Informatics (NCIBI)
 *         http://www.ncib.org.
 * 
 * This product may includes software developed by others; in that case see specific notes in the code. 
 * 
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation, 
 * either version 3 of the License, or (at your option) any later version, along with the following terms:
 * 1.   You may convey a work based on this program in accordance with section 5, 
 *      provided that you retain the above notices.
 * 2.   You may convey verbatim copies of this program code as you receive it, 
 *      in any medium, provided that you retain the above notices.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * 
 * See the GNU General Public License for more details, http://www.gnu.org/licenses/.
 * 
 * This work was supported in part by National Institutes of Health Grant #U54DA021519
 *
 ******************************************************************/

import java.util.Collection;

public class Main {
    public static String join(Collection<String> in, String joinS) {
        String ret = null;
        for (String s : in) {
            if (ret == null)
                ret = s;
            else
                ret += joinS + s;
        }
        if (ret == null)
            ret = "";
        return ret;
    }
}

Related

  1. join(Collection collection, String separator)
  2. join(Collection collection, String separator)
  3. join(Collection collection, String separator)
  4. join(Collection collection, String separator)
  5. join(Collection elements)
  6. join(Collection items)
  7. join(Collection items, String join)
  8. join(Collection items, String prefix, String suffix, String itemPrefix, String itemSuffix)
  9. join(Collection list)