Path implements IOReadableWritable, Serializable { public boolean isAbsolute() { final int start = hasWindowsDrive(uri.getPath(), true) ? 3 : 0; return uri.getPath().startsWith(SEPARATOR, start); } 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(); 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); static final String SEPARATOR; static final char SEPARATOR_CHAR; static final String CUR_DIR; }
@Test public void testIsAbsolute() { Path p = new Path("/my/abs/path"); assertTrue(p.isAbsolute()); p = new Path("/"); assertTrue(p.isAbsolute()); p = new Path("./my/rel/path"); assertFalse(p.isAbsolute()); p = new Path("my/rel/path"); assertFalse(p.isAbsolute()); p = new Path("C:/my/abs/windows/path"); assertTrue(p.isAbsolute()); p = new Path("y:/my/abs/windows/path"); assertTrue(p.isAbsolute()); p = new Path("/y:/my/abs/windows/path"); assertTrue(p.isAbsolute()); p = new Path("b:\\my\\abs\\windows\\path"); assertTrue(p.isAbsolute()); p = new Path("/c:/my/dir"); assertTrue(p.isAbsolute()); p = new Path("/C:/"); assertTrue(p.isAbsolute()); p = new Path("C:"); assertFalse(p.isAbsolute()); p = new Path("C:/"); assertTrue(p.isAbsolute()); p = new Path("C:my\\relative\\path"); assertFalse(p.isAbsolute()); p = new Path("\\my\\dir"); assertTrue(p.isAbsolute()); p = new Path("\\"); assertTrue(p.isAbsolute()); p = new Path(".\\my\\relative\\path"); assertFalse(p.isAbsolute()); p = new Path("my\\relative\\path"); assertFalse(p.isAbsolute()); p = new Path("\\\\myServer\\myDir"); assertTrue(p.isAbsolute()); }