Path implements Comparable, Serializable, ObjectInputValidation { public static Path mergePaths(Path path1, Path path2) { String path2Str = path2.toUri().getPath(); path2Str = path2Str.substring(startPositionWithoutWindowsDrive(path2Str)); return new Path(path1.toUri().getScheme(), path1.toUri().getAuthority(), path1.toUri().getPath() + path2Str); } Path(String parent, String child);  Path(Path parent, String child);  Path(String parent, Path child);  Path(Path parent, Path child);  Path(String pathString);  Path(URI aUri);  Path(String scheme, String authority, String path); static Path getPathWithoutSchemeAndAuthority(Path path); static Path mergePaths(Path path1, Path path2); static boolean isWindowsAbsolutePath(final String pathString,
                                              final boolean slashed); URI toUri(); FileSystem getFileSystem(Configuration conf); boolean isAbsoluteAndSchemeAuthorityNull(); boolean isUriPathAbsolute(); boolean isAbsolute(); boolean isRoot(); String getName(); Path getParent(); Path suffix(String suffix); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Object o); int depth(); @Deprecated Path makeQualified(FileSystem fs); @InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"}) Path makeQualified(URI defaultUri, Path workingDir ); @Override void validateObject(); void setScheme(String scheme); static final String SEPARATOR; static final char SEPARATOR_CHAR; static final String CUR_DIR; static final boolean WINDOWS; }
@Test (timeout = 30000) public void testMergePaths() { assertEquals(new Path("/foo/bar"), Path.mergePaths(new Path("/foo"), new Path("/bar"))); assertEquals(new Path("/foo/bar/baz"), Path.mergePaths(new Path("/foo/bar"), new Path("/baz"))); assertEquals(new Path("/foo/bar/baz"), Path.mergePaths(new Path("/foo"), new Path("/bar/baz"))); assertEquals(new Path(Shell.WINDOWS ? "/C:/foo/bar" : "/C:/foo/C:/bar"), Path.mergePaths(new Path("/C:/foo"), new Path("/C:/bar"))); assertEquals(new Path(Shell.WINDOWS ? "/C:/bar" : "/C:/C:/bar"), Path.mergePaths(new Path("/C:/"), new Path("/C:/bar"))); assertEquals(new Path("/bar"), Path.mergePaths(new Path("/"), new Path("/bar"))); assertEquals(new Path("viewfs: Path.mergePaths(new Path("viewfs: new Path("file: assertEquals(new Path("viewfs: Path.mergePaths(new Path("viewfs: new Path("file: }