Java Path Concatenate concatPath(String path0, String path1)

Here you can find the source of concatPath(String path0, String path1)

Description

concat Path

License

Open Source License

Declaration

public static final String concatPath(String path0, String path1) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final String concatPath(String path0, String path1) {

        if (path0 == null || path0.length() == 0) {
            return path1;
        }/*  w  w w .j a  va2 s  . c  o m*/
        if (path1 == null || path1.length() == 0) {
            return path0;
        }
        if (path0.endsWith("/")) {
            if (path1.startsWith("/")) {
                return path0 + path1.substring(1);
            } else {
                return path0 + path1;
            }
        } else {
            if (path1.startsWith("/")) {
                return path0 + path1;
            } else {
                return path0 + "/" + path1;
            }
        }
    }
}

Related

  1. concatPath(String path1, String path2)
  2. concatPath(String path1, String path2)
  3. concatPath(String path1, String path2)
  4. concatPath(String pathName, String name)