- java.lang.Object
-
- org.jline.builtins.ClasspathResourceUtil
-
public class ClasspathResourceUtil extends java.lang.ObjectUtility class for working with classpath resources.This utility provides methods to convert classpath resources to Path objects, which can be used with JLine's configuration classes like ConfigurationPath.
-
-
Constructor Summary
Constructors Constructor Description ClasspathResourceUtil()Creates a new ClasspathResourceUtil.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.nio.file.PathgetResourcePath(java.lang.String name)Converts a classpath resource to a Path.static java.nio.file.PathgetResourcePath(java.lang.String name, java.lang.Class<?> clazz)Converts a classpath resource to a Path.static java.nio.file.PathgetResourcePath(java.lang.String name, java.lang.ClassLoader classLoader)Converts a classpath resource to a Path.static java.nio.file.PathgetResourcePath(java.net.URL resource)Converts a URL to a Path.
-
-
-
Method Detail
-
getResourcePath
public static java.nio.file.Path getResourcePath(java.lang.String name) throws java.io.IOException, java.net.URISyntaxExceptionConverts a classpath resource to a Path.- Parameters:
name- The resource name (e.g., "/nano/jnanorc")- Returns:
- The Path to the resource
- Throws:
java.io.IOException- If an I/O error occursjava.net.URISyntaxException- If the resource URI is invalid
-
getResourcePath
public static java.nio.file.Path getResourcePath(java.lang.String name, java.lang.Class<?> clazz) throws java.io.IOException, java.net.URISyntaxExceptionConverts a classpath resource to a Path.- Parameters:
name- The resource name (e.g., "/nano/jnanorc")clazz- The class to use for resource loading- Returns:
- The Path to the resource
- Throws:
java.io.IOException- If an I/O error occursjava.net.URISyntaxException- If the resource URI is invalid
-
getResourcePath
public static java.nio.file.Path getResourcePath(java.lang.String name, java.lang.ClassLoader classLoader) throws java.io.IOException, java.net.URISyntaxExceptionConverts a classpath resource to a Path.- Parameters:
name- The resource name (e.g., "/nano/jnanorc")classLoader- The ClassLoader to use for resource loading- Returns:
- The Path to the resource
- Throws:
java.io.IOException- If an I/O error occursjava.net.URISyntaxException- If the resource URI is invalid
-
getResourcePath
public static java.nio.file.Path getResourcePath(java.net.URL resource) throws java.io.IOException, java.net.URISyntaxExceptionConverts a URL to a Path.For file:// URLs, returns a Path directly to the file. For jar: URLs, opens the JAR FileSystem and returns a Path within it. The returned Path is valid as long as the underlying FileSystem remains open.
Note: For jar: URLs, the FileSystem is created on first access and reused for subsequent accesses to the same JAR. The FileSystem will remain open for the lifetime of the application. Callers should not attempt to close the FileSystem as it may be shared with other code.
- Parameters:
resource- The URL to convert- Returns:
- The Path to the resource
- Throws:
java.io.IOException- If an I/O error occursjava.net.URISyntaxException- If the resource URI is invalid
-
-