java.lang.Object
net.foxgenesis.util.resource.ModuleResource
- Direct Known Subclasses:
FormattedModuleResource
A class that points to a resource inside a module and implements methods to
read from it.
- Author:
- Ashley
-
Constructor Summary
ConstructorsConstructorDescriptionModuleResource(Module module, String resource) ModuleResource(String moduleName, String resourcePath) -
Method Summary
Modifier and TypeMethodDescriptionRead this resource as aPropertiesfile.Get theModulecontaining this resource.Get the path to this resource.Open anInputStreamto this resource.String[]Read all lines from this resource.Read all data from this resource into a string.toString()voidwriteToFile(Path path, CopyOption... options) Copy this resource to the specified path.
-
Constructor Details
-
ModuleResource
- Parameters:
module- -Modulecontaining the resourceresource- - absolute path to the resource- Throws:
NullPointerException- If the module name or resource name are null- See Also:
-
ModuleResource
public ModuleResource(@Nonnull String moduleName, @Nonnull String resourcePath) throws NoSuchElementException - Parameters:
moduleName- - name of theModulecontaining the resourceresourcePath- - absolute path to the resource- Throws:
NullPointerException- If the module name or resource name are nullNoSuchElementException- If the module was not found- See Also:
-
-
Method Details
-
openStream
Open anInputStreamto this resource.- Returns:
- Returns an
InputStreamof this resource. - Throws:
IOException- If an I/O error occurs
-
writeToFile
Copy this resource to the specified path.- Parameters:
path- -Pathtp copy tooptions- - options specifying how the copy should be done- Throws:
IOException- If an I/O error occurs when reading or writing
-
readToString
Read all data from this resource into a string.- Returns:
- All data inside the resource as a string
- Throws:
IOException- If an I/O error occurs
-
readAllLines
Read all lines from this resource.- Returns:
- All data inside the resource as an array of strings
- Throws:
IOException- If an I/O error occurs
-
asProperties
Read this resource as aPropertiesfile.- Returns:
- Returns the parsed
Properties - Throws:
IOException- If an I/O error occurs
-
getModule
Get theModulecontaining this resource.- Returns:
- The containing
Module
-
getResourcePath
Get the path to this resource.- Returns:
- Returns the absolute path pointing to this resource
-
toString
-