Java Path Merge mergePaths(String part1, String part2)

Here you can find the source of mergePaths(String part1, String part2)

Description

merge Paths

License

Open Source License

Declaration

public static String mergePaths(String part1, String part2) 

Method Source Code

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

    }
}

Related

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