List of utility methods to do URI from
URI | toURI(String sUri) to URI try { return new URI(sUri); } catch (URISyntaxException e) { return null; |
URI | toURI(String uri) to URI if (uri == null) return null; return URI.create(uri); |
URI | toUri(String uri) to Uri return new URI(uri.replace(" ", "%20")); |
URI | toURI(String uri) Converts a string to a URI without a URISyntaxException try { return new URI(uri); } catch (URISyntaxException e) { throw new RuntimeException(e); |
URI | toURI(URI parent, String child) Convenient method to simulate a parent/child composition try { if (parent == null) { throw new IllegalArgumentException("Parent is null"); StringBuilder dirName = new StringBuilder(parent.toString()); if (dirName.charAt(dirName.length() - 1) != '/') { dirName.append('/'); if ((child == null) || child.isEmpty()) { throw new IllegalArgumentException("Child is null or empty"); if (child.startsWith("/")) { throw new IllegalArgumentException("Child is absolute: " + child); return new URI(dirName.append(child).toString()); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex.getMessage(), ex); |
URI[] | toURIArray(String[] array) Convert an array of strings into an array of URI instances. URI[] uris = new URI[array.length]; for (int i = 0; i < array.length; i++) { uris[i] = URI.create(array[i].trim()); return uris; |
List | toURIList(Collection to URI List List<URI> uriList = null; if (stringList != null && !stringList.isEmpty()) { uriList = new ArrayList<>(); for (String uriStr : stringList) { uriList.add(URI.create(uriStr)); return uriList; ... |
URI | toURIObject(String uri) to URI Object try { return new URI(uri); } catch (URISyntaxException e) { throw new IOException("Could not parse uri: " + uri + " - " + e.getMessage()); |
URI[] | toURIs(File... files) Convert files to URI in correct way. URI[] uris = new URI[files.length]; for (int i = 0; i < uris.length; i++) { uris[i] = files[i].toURI(); return uris; |
List | toURIs(Iterable to UR Is List<URI> urls = new ArrayList<URI>(); for (File file : files) { urls.add(file.toURI()); return urls; |