Package org.jline.builtins
Class ClasspathResourceUtil
java.lang.Object
org.jline.builtins.ClasspathResourceUtil
Utility 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic PathgetResourcePath(String name) Converts a classpath resource to a Path.static PathgetResourcePath(String name, Class<?> clazz) Converts a classpath resource to a Path.static PathgetResourcePath(String name, ClassLoader classLoader) Converts a classpath resource to a Path.static PathgetResourcePath(URL resource) Converts a URL to a Path.
-
Constructor Details
-
ClasspathResourceUtil
public ClasspathResourceUtil()Creates a new ClasspathResourceUtil.
-
-
Method Details
-
getResourcePath
Converts a classpath resource to a Path.- Parameters:
name- The resource name (e.g., "/nano/jnanorc")- Returns:
- The Path to the resource
- Throws:
IOException- If an I/O error occursURISyntaxException- If the resource URI is invalid
-
getResourcePath
public static Path getResourcePath(String name, Class<?> clazz) throws IOException, URISyntaxException Converts 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:
IOException- If an I/O error occursURISyntaxException- If the resource URI is invalid
-
getResourcePath
public static Path getResourcePath(String name, ClassLoader classLoader) throws IOException, URISyntaxException Converts 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:
IOException- If an I/O error occursURISyntaxException- If the resource URI is invalid
-
getResourcePath
Converts 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:
IOException- If an I/O error occursURISyntaxException- If the resource URI is invalid
-