java.lang.Object
net.foxgenesis.util.ResourceUtils
NEED_JAVADOC
- Author:
- Ashley
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PropertiesgetProperties(URL path) NEED_JAVADOCstatic PropertiesgetProperties(Path path, ModuleResource defaults) Parse aPropertiesfile at the specifiedPath.linesFromResource(URL path) Read all lines from a resourcestatic org.apache.commons.configuration2.INIConfigurationloadINI(ModuleResource defaults, Path dir, String output) Load an.iniconfiguration file from the specified directory and file.static org.apache.commons.configuration2.PropertiesConfigurationloadProperties(ModuleResource defaults, Path dir, String output) NEED_JAVADOCstatic String[]toSplitString(InputStream input) Read all data from the specifiedInputStreamand parse all lines as a string array.static StringtoString(InputStream input) Read all data from the specifiedInputStreamand parse it as a string.
-
Constructor Details
-
ResourceUtils
public ResourceUtils()
-
-
Method Details
-
linesFromResource
Read all lines from a resource- Parameters:
path- -URLpath to the resource- Returns:
- Returns all lines as a
List<String> - Throws:
IOException- Thrown if an error occurs while reading theInputStreamof the resource
-
getProperties
NEED_JAVADOC- Parameters:
path-- Returns:
- Throws:
IOException
-
getProperties
Parse aPropertiesfile at the specifiedPath. If the specified file was not found, the defaults will be written to its location.- Parameters:
path- - path to the properties filedefaults- - (optional) resource containing the default properties file- Returns:
- Returns a
Propertiesfile that was parsed from the specified path - Throws:
IOException- If an I/O error occursFileNotFoundException- If the specified file was not found and no defaults were given
-
loadProperties
public static org.apache.commons.configuration2.PropertiesConfiguration loadProperties(ModuleResource defaults, Path dir, String output) throws IOException, org.apache.commons.configuration2.ex.ConfigurationException NEED_JAVADOC- Parameters:
defaults-dir-output-- Returns:
- Throws:
IOExceptionorg.apache.commons.configuration2.ex.ConfigurationException
-
loadINI
public static org.apache.commons.configuration2.INIConfiguration loadINI(ModuleResource defaults, Path dir, String output) throws IOException, org.apache.commons.configuration2.ex.ConfigurationException Load an.iniconfiguration file from the specified directory and file. If the file is not found, the providedModuleResourcepointing to the configuration defaults will be used instead.- Parameters:
defaults- - resource containing the configuration defaultsdir- - the directory containing the configuration fileoutput- - the name of the configuration file- Returns:
- Returns the parsed
INIConfiguration - Throws:
IOException- If an I/O error occursorg.apache.commons.configuration2.ex.ConfigurationException- If an error occursSecurityException- Thrown if the specified file is not readable
-
toString
Read all data from the specifiedInputStreamand parse it as a string.The input stream will be closed after completion
- Parameters:
input- - the input stream to read- Returns:
- Returns a string containing the data from the specified input stream
- Throws:
IOException- If an I/O error occurs
-
toSplitString
Read all data from the specifiedInputStreamand parse all lines as a string array.The input stream will be closed after completion
This method is effectively equivalent to:
toString(input).split("(\\r\\n|\\r|\\n)")- Parameters:
input- - the input stream to read- Returns:
- Returns a string array containing the data from the specified input stream
- Throws:
IOException- If an I/O error occurs
-