Java Path Combine combinePath(String path1, String path2)

Here you can find the source of combinePath(String path1, String path2)

Description

combine Path

License

Apache License

Declaration

public static String combinePath(String path1, String path2) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    public static String combinePath(String path1, String path2) {

        if (path1.endsWith(File.separator) && path2.startsWith(File.separator)) {
            return path1 + path2.substring(1);
        }// w  w w. j  a  v a  2s  .c o m
        if (path1.endsWith(File.separator) || path2.startsWith(File.separator)) {
            return path1 + path2;
        }
        return path1 + File.separator + path2;
    }
}

Related

  1. combinePath(java.io.File parentDir, String... childDirs)
  2. combinePath(String basePath, String withPath)
  3. combinePath(String parent, String child)
  4. combinePath(String parent, String name)
  5. combinePath(String part0, String... parts)
  6. combinePath(String path1, String path2, String pathSeperator)
  7. combinePath(String... paths)
  8. combinePath(String... paths)
  9. combinePaths(final String path, final String... furtherPaths)