Paths { public static String getParentOf(String path) { int i = path.lastIndexOf(DELIM); return i == -1 ? null : path.substring(0, i); }  static String getNameOf(String path); static String getParentOf(String path); static String appended(String path, String child); static String renamed(String path, String newName); static String withoutRootIfUnder(String path, String root); static boolean isParent(String parent, String path); static boolean equals(String p1, String p2); static void setCaseSensitive(boolean b); static boolean isCaseSensitive(); static void useSystemCaseSensitivity();  }
@Test public void testParent() { assertEquals("dir1/dir2", Paths.getParentOf("dir1/dir2/file")); assertNull(Paths.getParentOf("file")); }