PathUtil { public static String getParentFolderPath(String path) { validatePath(path); int pos = path.lastIndexOf(StringPool.SLASH); if (pos == 0) { return StringPool.SLASH; } return path.substring(0, pos); }  static String buildPath(String folderPath, String name); static String getExtension(String path); static String getName(String path); static String getNameWithoutExtension(String path); static String getParentFolderPath(String path); static void validateName(String name); static void validatePath(String path);  }
@Test public void testGetParentFolderPathWithNonrootFolder() { Assert.assertEquals( "/folder", PathUtil.getParentFolderPath("/folder/name")); }
@Test public void testGetParentFolderPathWithRootFolder() { Assert.assertEquals("/", PathUtil.getParentFolderPath("/name")); }