Java Utililty Methods Path Concatenate

List of utility methods to do Path Concatenate

Description

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

Method

StringconcatPaths(String path1, String path2)
Concatenate two paths together, inserting a '/' if needed, and ensuring that there is no '//' at the join.
StringBuilder buffer = new StringBuilder(path1.length() + path2.length() + 1);
boolean endsWithSlash = path1.endsWith("/");
boolean beginsWithSlash = path2.startsWith("/");
buffer.append(path1);
if (!endsWithSlash) {
    buffer.append('/');
if (beginsWithSlash) {
...
StringconcatPaths(String prefix, String postfix)
Concatenates two paths using forward slashes.
String result = prefix;
if (!result.endsWith("/")) {
    result += "/";
result += postfix.startsWith("/") ? postfix.substring(1) : postfix;
return result;
StringconcatPathsStrings(String head, String tail)
concat Paths Strings
String result = null;
if (head.endsWith("/")) {
    if (tail.startsWith("/")) {
        result = head + tail.substring(1, tail.length());
    } else {
        result = head + tail;
} else {
...