use of org.jaffa.util.ListProperties in project jaffa-framework by jaffa-projects.
the class LabelHelper method loadPropertiesFromFile.
/**
* Reads the input file and loads its properties into a Properties object.
* @param fileName The file to be loaded.
* @param maintainFileFormat If true, then the comments and order for each property will be maintained.
* @throws IOException if any error occurs.
* @return a Properties object loaded with the properties from the input file.
*/
protected static Properties loadPropertiesFromFile(String fileName, boolean maintainFileFormat) throws IOException {
InputStream is = null;
Properties properties = null;
if (maintainFileFormat)
properties = new ListProperties();
else
properties = new Properties();
try {
File file = new File(fileName);
if (file.exists()) {
is = new BufferedInputStream(new FileInputStream(fileName));
properties.load(is);
if (log.isDebugEnabled())
log.debug("Loaded properties from " + fileName);
} else {
if (log.isDebugEnabled())
log.debug("No properties loaded, since file does not exist " + fileName);
}
return properties;
} finally {
if (is != null)
is.close();
}
}
Aggregations