Search in sources :

Example 6 with ListProperties

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();
    }
}
Also used : ListProperties(org.jaffa.util.ListProperties) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ListProperties(org.jaffa.util.ListProperties) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

ListProperties (org.jaffa.util.ListProperties)6 IOException (java.io.IOException)3 Iterator (java.util.Iterator)2 Properties (java.util.Properties)2 ApplicationResourceLoader (org.jaffa.config.ApplicationResourceLoader)2 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)2 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)2 PropertyMessageResources (org.jaffa.util.PropertyMessageResources)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 LabelEditorException (org.jaffa.applications.jaffa.modules.admin.components.labeleditor.ui.exceptions.LabelEditorException)1 LabelException (org.jaffa.exceptions.LabelException)1 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)1