public static String joinURL(String base, String[] paths) {
        StringBuilder result = new StringBuilder(base);
        Arrays.stream(paths).map(path -> path.replaceFirst("^(\\/)+", "")).forEach(p -> {
            if (result.lastIndexOf("/") != result.length() - 1) {
                result.append('/');
            }
            result.append(p);
        });
        return result.toString();
    }
public static String joinURL ( String base , String [ ] paths ) { StringBuilder result = new StringBuilder ( base ) ; Arrays . stream ( paths ) . map ( path -> path . replaceFirst ( "^(\\/)+" , "" ) ) . forEach ( p -> { if ( result . lastIndexOf ( "/" ) != result . length ( ) - 1 ) { result . append ( '/' ) ; } result . append ( p ) ; } ) ; return result . toString ( ) ; }
join a base url to another path or paths - this will handle trailing or non-trailing /'s