Java Utililty Methods URI to

List of utility methods to do URI to

Description

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

Method

StringextractParamsFromURI(String uri)
Extract a dispatch rule string from URI parameters (specified using example values)
if (uri.contains("?") && uri.contains("=")) {
    String parameters = uri.substring(uri.indexOf("?") + 1);
    StringBuilder params = new StringBuilder();
    for (String parameter : parameters.split("&")) {
        String[] pair = parameter.split("=");
        try {
            String key = URLDecoder.decode(pair[0], "UTF-8");
            String value = URLDecoder.decode(pair[1], "UTF-8");
...
StringextractS3Key(URI uri)
extract S Key
return uri.getPath().startsWith("/") ? uri.getPath().substring(1) : uri.getPath();
StringextractTargetSystemFromUri(URI uri)
extract Target System From Uri
return uri.getScheme();
StringextractURIFromText(String texto)
extract URI From Text
try {
    URI uri = new URI(texto);
    String suri = uri.toString();
    System.out.println(suri);
    return suri;
} catch (Exception e) {
    List<String> uris = extractUrls(texto);
    for (String uri : uris) {
...
StringtoDecodedString(URI uri)
Returns a string representation of the URI in a form suitable for human consumption.
String scheme = uri.getScheme();
String part = uri.getSchemeSpecificPart();
if (scheme == null)
    return part;
return scheme + ':' + part;
FiletoExistingFile(URI uri)
Returns a file object for uri which points to an existing file.
File result = null;
if (null != uri) {
    result = new File(uri);
    if (!result.exists()) {
        result = null;
return result;
...
StringtoExternalForm(URI u)
To fix the 3 slashes bug for File URI: For example: file:/C:/work/test.txt -> file:///C:/work/test.txt
StringBuilder sb = new StringBuilder();
if (u.getScheme() != null) {
    sb.append(u.getScheme());
    sb.append(':');
if (u.isOpaque()) {
    sb.append(u.getSchemeSpecificPart());
} else {
...
java.io.FiletoFile(java.net.URI uri)
to File
String str = uri.toString().substring(PREFIX.length());
try {
    return new java.io.File(new java.net.URI(str));
} catch (java.net.URISyntaxException urise) {
    throw new RuntimeException(str, urise);
FiletoFile(String filenameOrFileURI)
to File
if (schemePattern.matcher(filenameOrFileURI).matches()) {
    File f = new File(new URI(filenameOrFileURI));
    return f;
return new File(filenameOrFileURI);
FiletoFile(String unixPathOrUri)
to File
return isURI(unixPathOrUri) ? resolve(new File(toURI(unixPathOrUri)))
        : resolve(new File(unixPathOrUri.replace('/', File.separatorChar)));