Package org.goplanit.utils.resource
Class ResourceUtils
- java.lang.Object
- 
- org.goplanit.utils.resource.ResourceUtils
 
- 
 public class ResourceUtils extends Object Utilities to access resources in the Java environment- Author:
- markr
 
- 
- 
Constructor SummaryConstructors Constructor Description ResourceUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static FileSystemgetJarFileSystem(URI uri)Collect the jar as a FileSystem to access its internalsstatic InputStreamgetResourceAsInputStream(URI uri)Collect a resource input stream, which is either file based or not depending whether or not the resource is located in a jar or notstatic InputStreamReadergetResourceAsInputStreamReader(URI uri)Collect a resource input stream reader, which is either file based or not depending whether or not the resource is located in a jar or notstatic InputStreamgetResourceAsStream(String resourceLocation)Collect a resource as a stream based on provided locationstatic URIgetResourceUri(String resourceLocation)find the resource URI via this class' class loaderstatic URLgetResourceUrl(String resourceLocation)find the resource URL via this class' classloader.static URLgetResourceUrl(Path resourceLocation)find the resource URL via this class' classloader.
 
- 
- 
- 
Method Detail- 
getResourceUrlpublic static URL getResourceUrl(String resourceLocation) find the resource URL via this class' classloader. The resource location is expected to be a (relative) path with forward slashes. If the provided path contains backward slashes, these will be replaced to avoid issues- Parameters:
- resourceLocation- to find URL for
- Returns:
- the URL of the resource
 
 - 
getResourceUrlpublic static URL getResourceUrl(Path resourceLocation) find the resource URL via this class' classloader. The resource location is expected to be a (relative) path with forward slashes. If the provided path contains backward slashes, these will be replaced to avoid issues- Parameters:
- resourceLocation- to find URL for
- Returns:
- the URL of the resource
 
 - 
getResourceUripublic static URI getResourceUri(String resourceLocation) find the resource URI via this class' class loader- Parameters:
- resourceLocation- to find URI for
- Returns:
- the URI of the resource
 
 - 
getJarFileSystempublic static FileSystem getJarFileSystem(URI uri) throws IOException Collect the jar as a FileSystem to access its internals- Parameters:
- uri- to use
- Returns:
- FileSystem of Jar
- Throws:
- IOException- thrown if error
 
 - 
getResourceAsStreampublic static InputStream getResourceAsStream(String resourceLocation) Collect a resource as a stream based on provided location- Parameters:
- resourceLocation- to use
- Returns:
- input stream
 
 - 
getResourceAsInputStreamReaderpublic static InputStreamReader getResourceAsInputStreamReader(URI uri) Collect a resource input stream reader, which is either file based or not depending whether or not the resource is located in a jar or not- Parameters:
- uri- to deduce whether or not this resource resides within a jar or not, which drives the type of input reader that is to be created, if null we attempt to create it using the resourceLocation
- Returns:
- input stream reader created, or null if something happened
 
 - 
getResourceAsInputStreampublic static InputStream getResourceAsInputStream(URI uri) Collect a resource input stream, which is either file based or not depending whether or not the resource is located in a jar or not- Parameters:
- uri- to deduce whether or not this resource resides within a jar or not, which drives the type of input reader that is to be created, if null we attempt to create it using the resourceLocation
- Returns:
- input stream reader created, or null if something happened
 
 
- 
 
-