java.lang.Object
com.pervasive.datarush.commons.util.PropertiesFileUtil
Utility methods to consume properties files.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PropertiesLoads a JSON formatted string from a stream into aPropertiesobject.static PropertiesloadFromJSON(String filePath) Loads a JSON file from disk into aPropertiesobject.static PropertiesLoads a XML string from a stream into aPropertiesobject.static PropertiesloadFromXML(String filePath) Loads a XML file from disk into aPropertiesobject.static PropertiesLoads a.properties-formatted file from disk into aPropertiesobject.static Propertiesread(InputStream in) Loads a.properties-formatted string from a stream into aPropertiesobject.static PropertiesLoads a.properties-formatted file from disk into aPropertiesobject.static voidwrite(File propertiesFile, Properties data, String comment) Writes aPropertiesobject to disk.static voidwrite(String propertiesPath, Properties data, String comment) Writes aPropertiesobject to disk.
-
Constructor Details
-
PropertiesFileUtil
public PropertiesFileUtil()
-
-
Method Details
-
read
Loads a.properties-formatted file from disk into aPropertiesobject. On error, the input stream is properly closed and a user-friendly exception is thrown.- Parameters:
propertiesPath- the path to the file to load- Returns:
- a
Propertiesobject populated with the specified file's data
-
read
Loads a.properties-formatted file from disk into aPropertiesobject. On error, the input stream is properly closed and a user-friendly exception is thrown.- Parameters:
propertiesFile- the file to load- Returns:
- a
Propertiesobject populated with the specified file's data
-
read
Loads a.properties-formatted string from a stream into aPropertiesobject. However this method will not close the stream or handle exceptions directly.- Parameters:
in- inputstream containing properties- Returns:
- a
Propertiesobject populated with the specified file's data - Throws:
IOException
-
write
Writes aPropertiesobject to disk. On error, the output stream is properly closed and a user-friendly exception is thrown.- Parameters:
propertiesPath- the path to the file to writedata- thePropertiesobject to storecomment- an optional comment to include at the top of the written file
-
write
Writes aPropertiesobject to disk. On error, the output stream is properly closed and a user-friendly exception is thrown.- Parameters:
propertiesFile- the file to writedata- thePropertiesobject to storecomment- an optional comment to include at the top of the written file
-
loadFromJSON
Loads a JSON file from disk into aPropertiesobject. On error, the input stream is properly closed and a user-friendly exception is thrown.- Parameters:
filePath- the path to the file to load- Returns:
- a
Propertiesobject populated with the specified file's data
-
loadFromJSON
Loads a JSON formatted string from a stream into aPropertiesobject. However this method will not close the stream or handle exceptions directly.- Parameters:
in- inputstream containing properties in JSON format- Returns:
- a
Propertiesobject populated with the specified file's data - Throws:
IOException
-
loadFromXML
Loads a XML file from disk into aPropertiesobject. On error, the input stream is properly closed and a user-friendly exception is thrown.- Parameters:
filePath- the path to the file to load- Returns:
- a
Propertiesobject populated with the specified file's data
-
loadFromXML
Loads a XML string from a stream into aPropertiesobject. However this method will not close the stream or handle exceptions directly.- Parameters:
in- inputstream containing properties in XML format- Returns:
- a
Propertiesobject populated with the specified file's data - Throws:
IOException
-