Java Utililty Methods URI from

List of utility methods to do URI from

Description

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

Method

URItoURI(CharSequence uriStr)
Creates a URI from the passed string
try {
    return new URI(nvl(uriStr, "Passed string was null").toString());
} catch (Exception e) {
    throw new RuntimeException("Failed to create URL from string [" + uriStr + "]", e);
URItoURI(File f)
to URI
String s = f.getAbsolutePath();
if (File.separatorChar != '/') {
    s = s.replace(File.separatorChar, '/');
if (!s.startsWith("/")) {
    s = "/" + s;
if (!s.endsWith("/") && f.isDirectory()) {
...
URItoUri(File folder)
Translates platform specific path to independent form as URI
if (folder.exists() && !folder.isDirectory()) {
    throw new IllegalArgumentException("Invalid folder path: '" + folder + '\'');
return folder.toURI().normalize();
URItoURI(final java.io.File file, final StringBuilder builder)
A method to return a file URI from a file, without creating lots of char[] garbage.
java.io.File absoluteFile = file.getAbsoluteFile();
if (absoluteFile == null) {
    absoluteFile = new java.io.File(file.getAbsolutePath());
final String path = absoluteFile.getPath();
final int length = path.length();
final char separator = java.io.File.separatorChar;
int numStartSlashes = 0;
...
URItoURI(final String location)
to URI
return new URI(replace(location, " ", "%20"));
URItoURI(final String path)
Converts a URI string or file path to a URI object.
try {
    return new URI(path);
} catch (final URISyntaxException e) {
    try {
        final URL url = new URL(path);
        return new URI(url.getProtocol(), url.getHost(), url.getPath(), null);
    } catch (MalformedURLException | URISyntaxException nestedEx) {
        return new File(path).toURI();
...
URItoURI(final String uriString)
Creates a URI from the input string.
URI uri;
try {
    uri = new URI(uriString);
} catch (URISyntaxException e) {
    String encodedURIString = encodeUri(uriString);
    try {
        uri = new URI(encodedURIString);
    } catch (URISyntaxException e1) {
...
java.net.URItoUri(java.io.File file)
to Uri
if (file != null) {
    return file.toURI();
} else {
    return null;
URItoUri(String endpoint, Protocol protocol)
to Uri
if (endpoint == null) {
    throw new IllegalArgumentException("endpoint cannot be null");
if (!endpoint.contains("://")) {
    endpoint = protocol.toString() + "://" + endpoint;
try {
    return new URI(endpoint);
...
StringtoUri(String ip, String path)
to Uri
try {
    URL url = new URL(new URL(ip), path);
    return url.toExternalForm();
} catch (Exception e) {
    return null;