public final class URLs extends Object
Modifier and Type | Method and Description |
---|---|
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 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 |
relativize(URI base,
URI url) |
static URI |
resolve(URI base,
URI url) |
public static URL asURL(String url)
url
- An encoded absolute URLIllegalArgumentException
public static URL asURL(URI url)
url
- An encoded absolute URLIllegalArgumentException
public static URI asURI(String url)
url
- An encoded absolute or relative URLIllegalArgumentException
public static URI asURI(URL url)
url
- An encoded absolute or relative URLIllegalArgumentException
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 url)
base
- An encoded absolute or relative URLurl
- An encoded absolute or relative URLpublic 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–2025 The DAISY Consortium. All rights reserved.