Java tutorial
//package com.java2s; //License from project: Apache License import java.net.URI; import java.net.URISyntaxException; public class Main { public static String buildUri(String host, String path) { try { return new URI("https", host, "/" + path, null).toASCIIString(); } catch (URISyntaxException ex) { throw new AssertionError("URI creation failed, host=" + host + ", path=" + path, ex); } } }