Path implements IOReadableWritable, Serializable { public Path makeQualified(FileSystem fs) { Path path = this; if (!isAbsolute()) { path = new Path(fs.getWorkingDirectory(), this); } final URI pathUri = path.toUri(); final URI fsUri = fs.getUri(); String scheme = pathUri.getScheme(); String authority = pathUri.getAuthority(); if (scheme != null && (authority != null || fsUri.getAuthority() == null)) { return path; } if (scheme == null) { scheme = fsUri.getScheme(); } if (authority == null) { authority = fsUri.getAuthority(); if (authority == null) { authority = ""; } } return new Path(scheme + ":" + " } Path();  Path(URI uri);  Path(String parent, String child);  Path(Path parent, String child);  Path(String parent, Path child);  Path(Path parent, Path child);  Path(String pathString);  Path(String scheme, String authority, String path); URI toUri(); FileSystem getFileSystem(); boolean isAbsolute(); String getName(); String getPath(); Path getParent(); Path suffix(String suffix); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(Object o); int depth(); Path makeQualified(FileSystem fs); @Override void read(DataInputView in); @Override void write(DataOutputView out); boolean hasWindowsDrive(); static final String SEPARATOR; static final char SEPARATOR_CHAR; static final String CUR_DIR; }
@Test public void testMakeQualified() throws IOException { String path; Path p; URI u; path = "test/test"; p = new Path(path); u = p.toUri(); p = p.makeQualified(FileSystem.get(u)); u = p.toUri(); assertEquals("file", u.getScheme()); assertEquals(null, u.getAuthority()); assertEquals(FileSystem.getLocalFileSystem().getWorkingDirectory().toUri().getPath() + "/" + path, u.getPath()); path = "/test/test"; p = new Path(path); u = p.toUri(); p = p.makeQualified(FileSystem.get(u)); u = p.toUri(); assertEquals("file", u.getScheme()); assertEquals(null, u.getAuthority()); assertEquals(path, u.getPath()); }