public final class URLs extends Object
| Modifier and Type | Method and Description |
|---|---|
static Path |
asPath(URI uri)
Convert an absolute file URI to a
Path denoting a file or an entry in a zip file. |
static URI |
asURI(File file) |
static URI |
asURI(String url) |
static URI |
asURI(URL url) |
static URL |
asURL(File file) |
static URL |
asURL(String url) |
static URL |
asURL(URI url) |
static URI |
encode(URL url) |
static URI |
expand83(File file) |
static String |
expand83(String uri)
Expand 8.3 encoded path segments.
|
static File |
getCurrentJAR(Class<?> context) |
static URL |
getResourceFromJAR(String resource,
Class<?> context) |
static Path |
getResourceFromJAR(String resource,
Path jarFilePath)
Closing the file system of the returned path is the responsibility of the caller.
|
static Iterator<String> |
listResourcesFromJAR(String directory,
Class<?> context) |
static Iterator<String> |
listResourcesFromJAR(String directory,
Path jarFilePath) |
static URI |
normalize(URI uri) |
static URI |
normalize(URI uri,
boolean dropFragment) |
static URI |
relativize(URI base,
URI uri)
Relativize a URI against a base URI.
|
static URI |
resolve(URI base,
URI url) |
public static URL asURL(String url)
url - An encoded absolute URLIllegalArgumentExceptionpublic static URL asURL(URI url)
url - An encoded absolute URLIllegalArgumentExceptionpublic static URI asURI(String url)
url - An encoded absolute or relative URLIllegalArgumentExceptionpublic static URI asURI(URL url)
url - An encoded absolute or relative URLIllegalArgumentExceptionpublic static Path asPath(URI uri) throws IllegalArgumentException, URISyntaxException
Path denoting a file or an entry in a zip file.public static URI encode(URL url)
url - An unencoded absolute URLpublic static URI resolve(URI base, URI url)
base - An encoded absolute or relative URLurl - An encoded absolute or relative URLpublic static URI relativize(URI base, URI uri)
URI.relativize(java.net.URI) in that it is also able to find
relative paths when the URI does not start with the base URI (in which case the
resulting URI will contain ".." segments).base - An encoded absolute or relative URLurl - An encoded absolute or relative URLpublic static String expand83(String uri) throws URISyntaxException, IOException
URISyntaxExceptionIOExceptionpublic static URI expand83(File file) throws URISyntaxException, IOException
URISyntaxExceptionIOExceptionpublic static URL getResourceFromJAR(String resource, Class<?> context)
resource - The (not URL-encoded) path of a resource inside the specified JAR or class directorycontext - A class from the JAR or class directory that is to be searched for resourcespublic static Path getResourceFromJAR(String resource, Path jarFilePath)
public static Iterator<String> listResourcesFromJAR(String directory, Class<?> context)
directory - The (not URL-encoded) path of a directory inside the specified JAR or class directorycontext - A class from the JAR or class directory that is to be searched for resourcespublic static Iterator<String> listResourcesFromJAR(String directory, Path jarFilePath)
directory - The (not URL-encoded) path of a directory inside the specified JAR or class directoryjarFilePath - The location of the JAR file in a file system. Does not need to be be representable by a File.Copyright © 2010–2026 The DAISY Consortium. All rights reserved.