PathUtils { public static String addTrailingSlash(String path) { if (path == null) { return null; } if (!path.isEmpty() && path.charAt(path.length() - 1) == '/') { return path; } return path + "/"; }  static String join(String... paths); static String normalize(String path); static boolean isAbsolute(String path); static String removeLeadingSlash(String path); static String addLeadingSlash(String path); static String addTrailingSlash(String path);  }
@Test public void testAddTrailingSlash() { assertEquals("abc/", addTrailingSlash("abc")); assertEquals("/abc/abc/", addTrailingSlash("/abc/abc")); assertEquals("/abc/abc/", addTrailingSlash("/abc/abc/")); assertEquals("/", addTrailingSlash("")); }