Here you can find the source of concatenate(List
Parameter | Description |
---|---|
components | the list of URI fragments |
public static String concatenate(List<String> components)
//package com.java2s; /*/* w w w . j a va2 s.com*/ * The contents of this file are subject to the terms * of the Common Development and Distribution License * (the "License"). You may not use this file except * in compliance with the License. * * You can obtain a copy of the license at * http://www.opensource.org/licenses/cddl1.php * See the License for the specific language governing * permissions and limitations under the License. */ import java.util.List; public class Main { /** * Join a list of URI fragments into a URI using '/' as a separator. * @param components the list of URI fragments * @return the resulting URI */ public static String concatenate(List<String> components) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < components.size(); i++) { if (i > 0 && buf.charAt(buf.length() - 1) != '/' && components.get(i).charAt(0) != '/') buf.append('/'); buf.append(components.get(i)); } return buf.toString(); } }