Java Utililty Methods Path Merge

List of utility methods to do Path Merge

Description

The list of methods to do Path Merge are organized into topic(s).

Method

Stringmerge(String path, String relativePath)
merge
int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR);
if (separatorIndex != -1) {
    String newPath = path.substring(0, separatorIndex);
    if (!relativePath.startsWith(FOLDER_SEPARATOR)) {
        newPath += FOLDER_SEPARATOR;
    return newPath + relativePath;
} else {
...
Stringmerge(String path, String relativePath, boolean hasAuthority)
5.2.3.
String parent = path;
if (hasAuthority && parent.isEmpty()) {
    parent = SLASH;
return parent.substring(0, parent.lastIndexOf('/') + 1).concat(relativePath);
StringmergePath(String path1, String path2)
Merge two path to one path
String hp = path1 == null ? "" : path1;
String hb = path2 == null ? "" : path2;
String splider1 = "";
if (hp.endsWith("/") || hp.endsWith("\\")) {
    splider1 = hp.substring(hp.length() - 1, hp.length());
    hp = hp.substring(0, hp.length() - 1);
if (hb.startsWith("/") || hb.startsWith("\\")) {
...
StringmergePath(String... paths)
merge Path
String outPath = "";
for (String path : paths) {
    if (path != null) {
        outPath = mergePath(outPath, path);
return outPath.toString();
StringmergePaths(String part1, String part2)
merge Paths
if (part1.endsWith("/")) {
    if (part2.startsWith("/")) {
        return part1 + part2.substring(1);
    } else {
        return part1 + part2;
} else {
    if (part2.startsWith("/")) {
...