Java Utililty Methods URI Create

List of utility methods to do URI Create

Description

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

Method

URIgetURI(String bucket, String key)
get URI
try {
    return new URI("oss://" + bucket + "/" + key);
} catch (URISyntaxException e) {
    e.printStackTrace();
    return null;
URIgetURI(String host, int port, String path, boolean isHTTPS)
get URI
String myUrl = isHTTPS ? "https" : "http";
myUrl += "://" + host + ":" + port + path;
return new URI(myUrl);
StringGetURI(String host, String port, String resource)
Get URI
if (!resource.startsWith("/")) {
    resource = "/" + resource;
int portValue = 80;
if (port.length() > 0) {
    portValue = Integer.parseInt(port);
return new URL("http", host, portValue, resource).toURI().toString();
...
URIgetURI(String path)
get URI
if (path == null) {
    return null;
URI uri = new URI(path);
if (uri.getScheme() == null) {
    uri = new File(path).toURI();
return uri;
...
URIgetURI(String path)
get URI
if (path.contains(":/")) { 
    return URI.create(path);
} else {
    return new File(path).toURI();
URIgetURI(String path, String name)
Return a URI object for a filename with the given path
URI uri;
try {
    String URIstr = path + "/" + name;
    while (URIstr.indexOf(' ') > 0) {
        int spcLoc = URIstr.indexOf(' ');
        StringBuffer sb = new StringBuffer(URIstr);
        sb.replace(spcLoc, spcLoc + 1, "%20");
        URIstr = new String(sb);
...
URIgetURI(String protocol, String authority, String path, Hashtable params)
get URI
StringBuffer query = new StringBuffer();
if (query != null) {
    String key;
    for (Enumeration e = params.keys(); e.hasMoreElements();)
        query.append(key = (String) e.nextElement()).append("=").append((String) params.get(key))
                .append("&");
if (query.length() > 0)
...
URIgetUri(String s, String h, int p, String path)
Constructs the uri string and creates a URI object.
return getUri(s, null, h, p, path);
URIgetURI(String spec)
get URI
try {
    return new URI(spec);
} catch (URISyntaxException e) {
    throw new IllegalArgumentException("Don't know how to convert " + spec + " to URI");
URIgetUri(String uriName)
get Uri
try {
    return new URI(uriName);
} catch (Exception e) {
    throw new RuntimeException(e);