Here you can find the source of merge(String path, String relativePath)
public static String merge(String path, String relativePath)
//package com.java2s; //License from project: Open Source License public class Main { private static final String FOLDER_SEPARATOR = "/"; public static String merge(String path, String relativePath) { int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR); if (separatorIndex != -1) { String newPath = path.substring(0, separatorIndex); if (!relativePath.startsWith(FOLDER_SEPARATOR)) { newPath += FOLDER_SEPARATOR; }/* w w w . j a v a2 s . c o m*/ return newPath + relativePath; } else { return relativePath; } } }