Package ai.libs.jaicore.basic
Class ResourceUtil
- java.lang.Object
-
- ai.libs.jaicore.basic.ResourceUtil
-
public class ResourceUtil extends java.lang.Object
Utils for handling resource access in a more convenient way.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResourceFile
getResourceAsFile(java.lang.String path)
Returns the file corresponding to the given path.static java.lang.String
getResourceAsTempFile(java.lang.String resourcePath)
Creates a temporary file from the resource to load.static java.net.URL
getResourceAsURL(java.lang.String path)
Returns the file corresponding to the given path.static java.lang.String
readResourceFileToString(java.lang.String path)
Reads the contents of a resource to a string.static java.util.List<java.lang.String>
readResourceFileToStringList(ResourceFile resourceFile)
Reads the contents of a resource to a list of strings.static java.util.List<java.lang.String>
readResourceFileToStringList(java.lang.String path)
Reads the contents of a resource to a list of strings.
-
-
-
Method Detail
-
readResourceFileToString
public static java.lang.String readResourceFileToString(java.lang.String path) throws java.io.IOException
Reads the contents of a resource to a string.- Parameters:
path
- The path of the resource that shall be read.- Returns:
- The contents of the resource parsed to a string.
- Throws:
java.io.IOException
- Throws an IOException if the file could not be read.
-
readResourceFileToStringList
public static java.util.List<java.lang.String> readResourceFileToStringList(java.lang.String path) throws java.io.IOException
Reads the contents of a resource to a list of strings.- Parameters:
path
- The path of the resource that shall be read.- Returns:
- The contents of the resource parsed to a string.
- Throws:
java.io.IOException
- Throws an IOException if the file could not be read.
-
readResourceFileToStringList
public static java.util.List<java.lang.String> readResourceFileToStringList(ResourceFile resourceFile) throws java.io.IOException
Reads the contents of a resource to a list of strings.- Parameters:
resourceFile
- The resource file to read.- Returns:
- The contents of the resource parsed to a string.
- Throws:
java.io.IOException
- Throws an IOException if the file could not be read.
-
getResourceAsFile
public static ResourceFile getResourceAsFile(java.lang.String path)
Returns the file corresponding to the given path.- Parameters:
path
- The path for which a resource shall be retrieved.- Returns:
- The resource file corresponding to the given path.
- Throws:
java.io.IOException
-
getResourceAsURL
public static java.net.URL getResourceAsURL(java.lang.String path)
Returns the file corresponding to the given path.- Parameters:
path
- The path for which a resource shall be retrieved.- Returns:
- The resource file corresponding to the given path.
- Throws:
java.io.IOException
-
getResourceAsTempFile
public static java.lang.String getResourceAsTempFile(java.lang.String resourcePath)
Creates a temporary file from the resource to load.- Parameters:
resourcePath
- The path to the resource.- Returns:
- The canonical path to the temporary file reflecting the contents of the resource.
-
-