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

URIcreateURI(String path)
create URI
return new URI(path.replaceAll(" ", "%20"));
URIcreateURI(String path)
Creates a URI from a path, the path can be relative or absolute, '\' and '/' are normalised.
path = path.replace('\\', '/');
return URI.create(encodeURI(path));
URIcreateURI(String scheme, String host, String path)
create URI
String uri = scheme + "://" + host + path;
return createURI(uri);
URIcreateURI(String spec)
create URI
if (null == spec) {
    return null;
} else {
    return new URI(spec);
URIcreateUri(String sUri, String defaultSchema, int deafultPort)
It creates an URI from a String.
String schema = defaultSchema;
String host = null;
int port = deafultPort;
String path = "";
int index = sUri.indexOf("://");
if (index > -1) {
    schema = sUri.substring(0, index);
    sUri = sUri.substring(index + 3, sUri.length());
...
URIcreateUri(String u)
create Uri
URI uri = URI.create(u);
final String scheme = uri.getScheme();
if (scheme == null || !scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) {
    throw new IllegalArgumentException(
            "The URI scheme, of the URI " + u + ", must be equal (ignoring case) to 'http' or 'https'");
String path = uri.getPath();
if (path == null) {
...
URIcreateUri(String uri)
Creates a URI from the specified string without throwing a URISyntaxException.
try {
    return new URI(uri);
} catch (URISyntaxException e) {
    return EMPTYURI;
URIcreateURI(String uri)
create URI
return URI.create("//" + parseCorrectURI(uri));
URIcreateURI(String uri)
Convenience method to turn a String into a URI without throwing any pesky checked exceptions.
try {
    return new URI(uri);
} catch (URISyntaxException e) {
    throw (IllegalArgumentException) new IllegalArgumentException("Bad URI: " + uri).initCause(e);
URIcreateURI(String uri)
Escape the space in URL string
if (uri == null) {
    return null;
if (uri.indexOf('%') != -1) {
    return URI.create(uri);
int index = uri.indexOf(':');
String scheme = null;
...