Java Utililty Methods URL Create

List of utility methods to do URL Create

Description

The list of methods to do URL Create are organized into topic(s).

Method

URLcreateURL(String url, String baseURI)
Create URL using base URI.
URL returnURL = null;
URI uri = null;
try {
    returnURL = new URL(url);
    uri = new URI(url);
    uri = uri.normalize();
    returnURL = new URL(uri.toString());
catch (Exception mue) {
    int i = baseURI.lastIndexOf('/');
    int j = baseURI.lastIndexOf('\\');
    if (j > i)
        i = j;
    try {
        uri = new URI(baseURI.substring(0, i + 1) + url);
        uri = uri.normalize();
        returnURL = uri.toURL();
    } catch (Exception e) {
        return new URL(baseURI.substring(0, i + 1) + url);
return returnURL;
URLcreateURL(String urlString)
Create a URL from a string.
return new URL(urlString);
StringtoUrl(String filename)
to Url
String url = "file:///" + filename.replace('\\', '/');
return url;
StringtoURL(String port, String address, String table)
to URL
return "jdbc:mysql://" + address + ":" + port + "/" + table + "?autoReconnect=true&useSSL=false";
StringtoURL(String protocol, String host, int port, String path)
to URL
StringBuilder sb = new StringBuilder();
sb.append(protocol).append("://");
sb.append(host).append(':').append(port);
if (path.charAt(0) != '/')
    sb.append('/');
sb.append(path);
return sb.toString();
StringtoUrl(String s)
Creates a value of the formed expected by SVG href attribtues.
return "url(#" + s + ")";
StringtoUrl(String url)
Converts '\\' to '/' in URL
return url.replace("\\", "/");
StringtoUrlDate(String date)
to Url Date
String[] s = date.split("-");
String da = s[2] + "-" + s[1] + "-" + s[0];
return da;
StringtoUrlPagePath(String pagePath)
Converts a page path from real format to URL format.
return (pagePath != null) ? pagePath.replace('/', ',') : null;
StringtoUrlParameterString(String fenString)
to Url Parameter String
return fenString.replace(' ', '.').replace('/', '_');