PathUtil { public static String getTarget(final String fullPath) { if (fullPath == null) { return ""; } final String[] splitString = fullPath.split("/"); final int length = splitString.length; if (length == 0) { return ""; } else { return splitString[splitString.length - 1]; } } private  PathUtil(); static String getTarget(final String fullPath);  }
@Test public void testGetTarget() { assertEquals("File.java", PathUtil.getTarget("trunk/src/File.java")); assertEquals("src", PathUtil.getTarget("trunk/src/")); assertEquals("src", PathUtil.getTarget("trunk/src")); assertEquals("", PathUtil.getTarget("")); assertEquals("", PathUtil.getTarget("/")); assertEquals("", PathUtil.getTarget(null)); }