Here you can find the source of mergePaths(String part1, String part2)
public static String mergePaths(String part1, String part2)
//package com.java2s; public class Main { public static String mergePaths(String part1, String part2) { if (part1.endsWith("/")) { if (part2.startsWith("/")) { return part1 + part2.substring(1); } else { return part1 + part2; }//from ww w.ja v a2 s. c o m } else { if (part2.startsWith("/")) { return part1 + part2; } else { return part1 + (part2.equals("") ? "" : "/") + part2; } } } }