List of utility methods to do URI Create
String | getUriScheme(String address) get Uri Scheme try { URI addrURI = new URI(address); String scheme = addrURI.getScheme(); return scheme != null ? scheme : HTTP; } catch (URISyntaxException e) { return HTTP; |
String | getURIsPrettyPrint(final Collection Returns a string describing of a collection of URI objects. final StringBuilder builder = new StringBuilder(uris.size() << 4).append("[ "); for (URI uri : uris) builder.append(uri.getFragment()).append(", "); builder.replace(builder.length() - 2, builder.length(), " ]"); return builder.toString(); |
InputStream | getURIStream(Object obj) get URI Stream if (obj instanceof File) { return new BufferedInputStream(new FileInputStream((File) obj)); else if (obj instanceof URI) { return ((URI) obj).toURL().openStream(); return null; |
URI | getURIWithAuthority(URI uri, String authority) Converts URI to a URI with the given authority. try { if (uri.getScheme() == null) return new URI("file", uri.getPath(), null); if ("gitfs".equals(uri.getScheme())) return new URI(uri.getScheme(), authority, uri.getPath(), uri.getQuery(), uri.getFragment()); return uri; } catch (URISyntaxException e) { e.printStackTrace(); ... |
URI | stringToUri(String fileString) string To Uri return new File(fileString).toURI(); |
URI[] | stringToURI(String[] str) string To URI if (str == null) return null; URI[] uris = new URI[str.length]; for (int i = 0; i < str.length; i++) { try { uris[i] = new URI(str[i]); } catch (URISyntaxException ur) { throw new IllegalArgumentException("Failed to create uri for " + str[i], ur); ... |
URI | uri(String host, String prefix, String path) uri String name = host; int port = 80; int index = host.indexOf(':'); if (index > 0) { String[] split = host.split(":"); name = split[0]; port = Integer.valueOf(split[1]); return new URI("http", null, name, port, prefix + "/" + path, null, null); |
URI | uri(String path) uri return new URI("http", null, HOST, PORT, path, null, null); |
URI | uri(String str) uri try { return new URI(str); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); |
URI | uri(String uri) uri try { return new URI(uri); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); |