Java Collection to String collectionToString(Collection collection, String seperator)

Here you can find the source of collectionToString(Collection collection, String seperator)

Description

collection To String

License

Open Source License

Declaration

public static String collectionToString(Collection<? extends Object> collection, String seperator) 

Method Source Code

//package com.java2s;
/*//from ww w .j a  v a2  s . c o  m
 * 
 * Copyright 2012 lexergen.
 * This file is part of lexergen.
 * 
 * lexergen 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.
 * 
 * lexergen 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.
 * 
 * You should have received a copy of the GNU General Public License
 * along with lexergen.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * lexergen:
 * A tool to chunk source code into tokens for further processing in a compiler chain.
 * 
 * Projectgroup: bi, bii
 * 
 * Authors: Johannes Dahlke
 * 
 * Module:  Softwareprojekt ?bersetzerbau 2012 
 * 
 * Created: Apr. 2012 
 * Version: 1.0
 *
 */

import java.util.Collection;
import java.util.Iterator;

public class Main {

    public static String collectionToString(Collection<? extends Object> collection, String seperator) {
        String result = "";
        for (Iterator<? extends Object> iterator = collection.iterator(); iterator.hasNext();) {
            String string = iterator.next().toString();
            if (result.length() == 0)
                result += string;
            else
                result += seperator + string;
        }
        return result;
    }
}

Related

  1. collectionToString(Collection collection, String delim)
  2. collectionToString(Collection list, String split)
  3. collectionToString(Collection set)
  4. collectionToString(Collection c)
  5. collectionToString(Collection collection, String delimiter)
  6. collectionToString(Collection list, String delimiter)
  7. collectionToString(Collection c)
  8. collectionToString(Collection c)
  9. collectionToString(Collection c)