List of utility methods to do URI from
URI | toURI(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); |
URI | toURI(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()) { ... |
URI | toUri(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(); |
URI | toURI(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; ... |
URI | toURI(final String location) to URI return new URI(replace(location, " ", "%20")); |
URI | toURI(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(); ... |
URI | toURI(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.URI | toUri(java.io.File file) to Uri if (file != null) { return file.toURI(); } else { return null; |
URI | toUri(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); ... |
String | toUri(String ip, String path) to Uri try { URL url = new URL(new URL(ip), path); return url.toExternalForm(); } catch (Exception e) { return null; |