Java Path Merge merge(String path, String relativePath)

Here you can find the source of merge(String path, String relativePath)

Description

merge

License

Open Source License

Declaration

public static String merge(String path, String relativePath) 

Method Source Code

//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;
        }
    }
}

Related

  1. merge(String path, String relativePath, boolean hasAuthority)
  2. mergePath(String path1, String path2)
  3. mergePath(String... paths)
  4. mergePaths(String part1, String part2)