Here you can find the source of toURL(String protocol, String host, int port, String path)
public static String toURL(String protocol, String host, int port, String path)
//package com.java2s; //License from project: Apache License public class Main { public static String toURL(String protocol, String host, int port, String path) { StringBuilder sb = new StringBuilder(); sb.append(protocol).append("://"); sb.append(host).append(':').append(port); if (path.charAt(0) != '/') sb.append('/'); sb.append(path);// w w w. java 2s . c o m return sb.toString(); } }