PathUtil { public static String getName(String path) { if (path == "/") { return "/"; } List<String> groups = RegexUtil.groups("^+(([^/]+))/*$", path); return groups.get(1); }  static String parentPath(String path); static String fix(String path); static String getExtention(String path); static String concatPath(String path, String child); static String removeExtention(String path); static String getName(String path); static String toUrl(URL resource); static String toUrl(String url); static List<String> split(String path);  }
@Test public void testGetName() { assertEquals("xyz.txt", PathUtil.getName("xyz.txt")); assertEquals("xyz.txt", PathUtil.getName("/xyz.txt")); assertEquals("xyz.txt", PathUtil.getName("/abc/fff/xyz.txt")); assertEquals("xyz.txt", PathUtil.getName("xyz.txt/")); assertEquals("xyz.txt", PathUtil.getName("/xyz.txt/")); assertEquals("xyz.txt", PathUtil.getName("/abc/fff/xyz.txt/")); assertEquals("/", PathUtil.getName("/")); assertEquals("xyz.txt", PathUtil.getName(" }