PathUtil { public static String buildPath(String folderPath, String name) { validatePath(folderPath); validateName(name); if (folderPath.equals(StringPool.SLASH)) { return StringPool.SLASH + name; } return folderPath + StringPool.SLASH + name; }  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 testBuildPathWithNonrootFolder() { Assert.assertEquals( "/folderPath/name", PathUtil.buildPath("/folderPath", "name")); }
@Test public void testBuildPathWithRootFolder() { Assert.assertEquals( "/name", PathUtil.buildPath(StringPool.SLASH, "name")); }