PathUtils { public static String join(String... paths) { String joined = Stream.of(paths) .filter(p -> p != null && !p.isEmpty()) .collect(Collectors.joining("/")); return normalize(joined); }  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 plainJoin() { assertEquals("abc", join("abc")); assertEquals("aa/bb", join("aa", "bb")); assertEquals("/aa/bb", join("/aa", "bb")); assertEquals("/aa/bb", join("/aa", "/bb")); assertEquals("/aa/bb/", join("/aa", "/bb/")); }
@Test public void emptyArgumentsJoin() { assertEquals("", join()); assertEquals("aa", join("aa", null)); assertEquals("aa/bb", join("aa", "", "bb")); }
@Test public void normalizeJoin() { assertEquals("bb", join("./aa", "../bb")); assertEquals("aa/bb", join("./aa", "./bb")); }