Java Path to URL getUrl(String ip, String port, String servicePath, String serviceName, String... args)

Here you can find the source of getUrl(String ip, String port, String servicePath, String serviceName, String... args)

Description

get Url

License

Mozilla Public License

Declaration

public static String getUrl(String ip, String port, String servicePath, String serviceName, String... args)
            throws UnsupportedEncodingException 

Method Source Code

//package com.java2s;
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    public static String getUrl(String ip, String port, String servicePath, String serviceName, String... args)
            throws UnsupportedEncodingException {
        StringBuilder params = new StringBuilder();
        params.append("http://");
        params.append(ip);/*ww w.  j a  v  a2s.c  o m*/
        params.append(":");
        params.append(port);
        params.append(servicePath);
        params.append(serviceName);

        // args
        for (String arg : args) {
            params.append("/");
            params.append(URLEncoder.encode(arg, "UTF-8"));
        }

        return params.toString();
    }
}

Related

  1. getUriNormalizedContainerAndPathWithoutSlash(String stringUriValue, String containerUrl, boolean normalizeUrlMode, boolean matchBaseUrlMode)
  2. getURL(String aPath)
  3. getUrl(String baseUrl, String absPath)
  4. getURL(String host, int port, String path, boolean isHTTPS)
  5. getUrl(String inPath)
  6. getURL(String path)
  7. getURL(String path)
  8. getURL(String path, URL context)
  9. getUrl(String pluginId, String relativePath)