Java URL Build buildURLForParamsWithPrefix(String prefix, String... urlParams)

Here you can find the source of buildURLForParamsWithPrefix(String prefix, String... urlParams)

Description

Returns a URL created from the given params and with the given prefix

License

Apache License

Parameter

Parameter Description
prefix given prefix
urlParams given params

Return

URL with the given params and prefix

Declaration

public static String buildURLForParamsWithPrefix(String prefix, String... urlParams) 

Method Source Code

//package com.java2s;
/*//from w ww .  ja v  a 2 s.  co  m
   Copyright 2013 Rene Nowak 
    
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
    
   http://www.apache.org/licenses/LICENSE-2.0
    
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

public class Main {
    /**
     * Returns a URL created from the given params and with the given prefix
     *
     * @param prefix given prefix
     * @param urlParams given params
     * @return URL with the given params and prefix
     */
    public static String buildURLForParamsWithPrefix(String prefix, String... urlParams) {
        String url = "/" + prefix + buildURLForParams(urlParams);
        return url;
    }

    /**
     * Returns a URL created from the given params
     *
     * @param urlParams given params
     * @return URL with the given params
     */
    public static String buildURLForParams(String... urlParams) {
        String url = "/";
        for (String param : urlParams) {
            url += param + "/";
        }
        return url;
    }
}

Related

  1. buildUrl(String scheme, String host, int port)
  2. buildUrl(String uri)
  3. buildUrl(String[] indexNames, String[] types, String operationOrId)
  4. buildUrlAsString(String scheme, String host, int port, String path)
  5. buildURLForParams(String... urlParams)
  6. buildURLForPath(String[] _path)
  7. buildUrlFromParts(String... parts)
  8. buildUrlWithFilter(String url, String[] filterArrayString)
  9. queryString(final Map> params)