Java List Join join(List strList, char separator)

Here you can find the source of join(List strList, char separator)

Description

join

License

Open Source License

Declaration

public static String join(List<String> strList, char separator) 

Method Source Code

//package com.java2s;
/*/*w w  w .ja  v  a  2  s.c  o  m*/
 * Copyright (c) 2004-2012 The YAWL Foundation. All rights reserved.
 * The YAWL Foundation is a collaboration of individuals and
 * organisations who are committed to improving workflow technology.
 *
 * This file is part of YAWL. YAWL is free software: you can
 * redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation.
 *
 * YAWL 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 Lesser General
 * Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with YAWL. If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.*;

public class Main {
    public static String join(List<String> strList, char separator) {
        if (strList == null || strList.isEmpty())
            return "";
        if (strList.size() == 1)
            return strList.get(0);
        StringBuilder sb = new StringBuilder();
        for (String s : strList) {
            if (sb.length() > 0)
                sb.append(separator);
            sb.append(s);
        }
        return sb.toString();
    }
}

Related

  1. join(List strings, String separator)
  2. join(List strings, String separator)
  3. join(List strings, String separator)
  4. join(List strings, String separator)
  5. join(List stringsToJoin, char delimiter)
  6. join(List strList, String sep)
  7. join(List tokens, String sep)
  8. join(List tokens, String separator)
  9. join(List tokens, String separator)