Package io.extact.rms.platform.util
Class ResourceUtils
java.lang.Object
io.extact.rms.platform.util.ResourceUtils
Class resource utility.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
extractFilePathStringOfUrl
(URL resourceUrl) Extract the character string of the Jar file path part from the resource URL in the jar.findResoucePathUnder
(String targetDir) Get the class resource under the path specified by the argument by URL.findResoucePathUnder
(String targetDir, Predicate<Object> fileFilter, ClassLoader classLoader) Get the class resource under the path specified by the argument by URL.static File
toJarFileFromResourceUrl
(URL resourceUrl) Make a jar file on the file system based on the resource URL in the jar.
-
Constructor Details
-
ResourceUtils
public ResourceUtils()
-
-
Method Details
-
findResoucePathUnder
Get the class resource under the path specified by the argument by URL. Search also inside the jar file.Also, if a file is specified in the argument path, the URL of the corresponding file is returned. The following usage exampleclasspath-resources => jar:file:/C:/foo/bar/baz.jar!/META-INF/MANIFEST.MF jar:file:/C:/foo/bar/baz.jar!/mpconfig/a.properties jar:file:/C:/foo/bar/baz.jar!/mpconfig/b.properties file:/C:/for/bar/target/classes/message.properties file:/C:/for/bar/target/classes/mpconfig/c.text targetDir => mpconfig return url => jar:file:/C:/foo/bar/baz.jar!/mpconfig/a.properties jar:file:/C:/foo/bar/baz.jar!/mpconfig/b.properties file:/C:/for/bar/target/classes/mpconfig/c.text
- Parameters:
targetDir
- Path to search for resources. Do not add `/` at the beginning- Returns:
- URL of the target resource. Returns an empty list if not applicable.
- Throws:
IOException
- IO error occurs.
-
findResoucePathUnder
public static List<URL> findResoucePathUnder(String targetDir, Predicate<Object> fileFilter, ClassLoader classLoader) throws IOException Get the class resource under the path specified by the argument by URL.- Throws:
IOException
- See Also:
-
toJarFileFromResourceUrl
Make a jar file on the file system based on the resource URL in the jar.- Parameters:
resourceUrl
- Resource URL in the jar.- Returns:
- File object in jar.
-
extractFilePathStringOfUrl
Extract the character string of the Jar file path part from the resource URL in the jar.- Parameters:
resourceUrl
- Resource URL in the jar.- Returns:
- String of FilePath.
-