src/main/java/com/github/jillesvangurp/urlbuilder/UrlBuilder.java
public UrlBuilder append(boolean encode,String... postFix) {
        for (String part : postFix) {
            if(StringUtils.isNotBlank(part)) {
                if (url.charAt(url.length() - 1) != '/' && !part.startsWith("/")) {
                    url.append('/');
                }
                if(encode) {
                    try {
                        url.append(URLEncoder.encode(part, "UTF-8"));
                    } catch (UnsupportedEncodingException e) {
                        throw new IllegalStateException(e);
                    }
                } else {
                    url.append(part);
                }
            }
        }
        return this;
    }
public UrlBuilder append(boolean encode,String... postFix) {
        for (String part : postFix) {
            if(StringUtils.isNotBlank(part)) {
                if (url.charAt(url.length() - 1) != '/' && !part.startsWith("/")) {
                    url.append('/');
                }
                if(encode) {
                    try {
                        url.append(URLEncoder.encode(part, "UTF-8"));
                    } catch (UnsupportedEncodingException e) {
                        throw new IllegalStateException(e);
                    }
                } else {
                    url.append(part);
                }
            }
        }
        return this;
    }
public UrlBuilder append ( boolean encode , String ... postFix ) { for ( String part : postFix ) { if ( StringUtils . isNotBlank ( part ) ) { if ( url . charAt ( url . length ( ) - 1 ) != ' ' && ! part . startsWith ( "/" ) ) { url . append ( ' ' ) ; } if ( encode ) { try { url . append ( URLEncoder . encode ( part , "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException ( e ) ; } } else { url . append ( part ) ; } } } return this ; }
Appends one or more postfixes and separates them by slashes.
@param encode if true, the postFixes are url encoded.
@param postFix one or more String values
@return the builder
Appends one or more postfixes and separates them by slashes .