Here you can find the source of join(List
Parameter | Description |
---|---|
parts | string parts |
separator | separator |
public static String join(List<String> parts, String separator)
//package com.java2s; /*//from ww w. j a va2 s. c o m * This is part of Geomajas, a GIS framework, http://www.geomajas.org/. * * Copyright 2008-2013 Geosparc nv, http://www.geosparc.com/, Belgium. * * The program is available in open source according to the GNU Affero * General Public License. All contributions in this program are covered * by the Geomajas Contributors License Agreement. For full licensing * details, see LICENSE.txt in the project root. */ import java.util.Iterator; import java.util.List; public class Main { /** * Joins a list of strings using the specified separator. * * @param parts string parts * @param separator separator * @return concatenated string */ public static String join(List<String> parts, String separator) { Iterator<String> it = parts.iterator(); StringBuilder builder = new StringBuilder(); while (it.hasNext()) { String part = it.next(); builder.append(part); if (it.hasNext()) { builder.append(separator); } } return builder.toString(); } }