Java Utililty Methods Path Combine

List of utility methods to do Path Combine

Description

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

Method

Stringcombine(final String path, final String suffix)
combine
if (isEmpty(path) && isEmpty(suffix)) {
    return "";
if (isEmpty(path)) {
    return suffix;
if (isEmpty(suffix)) {
    return path;
...
Stringcombine(final String path1, final String path2)
combine
if (path1.endsWith("/") || path1.endsWith(System.getProperty("file.separator"))) {
    return path1 + path2;
} else {
    return path1 + System.getProperty("file.separator") + path2 + System.getProperty("file.separator");
Stringcombine(String directory, String filename)
combine
if (!directory.endsWith("/") && !directory.endsWith("\\"))
    directory = directory + "/";
String path = directory + filename;
return path;
StringcombineDisplayPaths(String parent_display, String display_path)
Combine display paths
if (parent_display == null || parent_display.isEmpty())
    return display_path;
display_path = normalize(display_path);
if (isAbsolute(display_path))
    return display_path;
parent_display = normalize(parent_display);
String result = getDirectory(parent_display) + "/" + display_path;
result = normalize(result);
...
StringcombinePath(java.io.File parentDir, String... childDirs)
[Combine MultiplePaths] java alternative (OS independent) to System.IO.Path.Combine().
java.io.File path = parentDir;
for (String childDir : childDirs) {
    path = new java.io.File(path, childDir);
return path.getPath();
StringcombinePath(String basePath, String withPath)
combine Path
if (basePath == null)
    basePath = "";
if (withPath == null)
    withPath = "";
String prefix = basePath.endsWith("/") ? basePath : basePath + "/";
String suffix = withPath.startsWith("/") ? withPath.substring(1) : withPath;
return prefix + suffix;
StringcombinePath(String parent, String child)
path is combined and normalized.
if (parent == null && child == null) {
    return null;
} else if (parent == null || parent.length() == 0) {
    return normalize(child);
} else if (child == null || child.length() == 0) {
    return normalize(parent);
child = normalize(child);
...
StringcombinePath(String parent, String name)
combine Path
if (parent.endsWith("/")) {
    return parent + name;
} else {
    return parent + "/" + name;
StringcombinePath(String part0, String... parts)
combine Path
final StringBuilder builder = new StringBuilder();
builder.append(part0);
for (String part : parts) {
    builder.append(File.separatorChar);
    builder.append(part);
return builder.toString();
StringcombinePath(String path1, String path2)
combine Path
if (path1.endsWith(File.separator) && path2.startsWith(File.separator)) {
    return path1 + path2.substring(1);
if (path1.endsWith(File.separator) || path2.startsWith(File.separator)) {
    return path1 + path2;
return path1 + File.separator + path2;