/** * Concatenates the two urls with respect to leading and trailing slashes. The path will always end with a trailing * slash. * * @return the concatenated url of the two arguments */ public static String concat(String prefix, String suffix, boolean close) { if (prefix == null) throw new IllegalArgumentException("Argument prefix is null"); if (suffix == null) throw new IllegalArgumentException("Argument suffix is null"); prefix = checkSeparator(prefix); suffix = checkSeparator(suffix); prefix = removeDoubleSeparator(prefix); suffix = removeDoubleSeparator(suffix); if (!prefix.endsWith("/") && !suffix.startsWith("/")) prefix += "/"; if (prefix.endsWith("/") && suffix.startsWith("/")) suffix = suffix.substring(1); prefix += suffix; // Close? if (close && !prefix.endsWith("/")) { prefix += "/"; } return prefix; }