Here you can find the source of combinePaths(String... items)
public static String combinePaths(String... items)
//package com.java2s; public class Main { /** Simplifies the way to combine paths. Takes care about normalization. */ public static String combinePaths(String... items) { if (items.length == 0) { return ""; }// w ww . j ava2 s.c o m StringBuilder sb = new StringBuilder(items[0]); for (int i = 1; i < items.length; i++) { if (!items[i - 1].endsWith("/")) { sb.append("/"); } if (items[i].startsWith("/")) { sb.append(items[i].substring(1)); } else { sb.append(items[i]); } } return sb.toString(); } }