Code example for Properties

Methods: loadFromXML, setProperty, storeToXML

0
    } 
 
    private void addEntry(File keystoreFile, ViewStateEntry stateEntry) throws IOException
    { 
        Properties prop = load();
        prop.setProperty(keystoreFile.getAbsolutePath(), write(stateEntry));
        store(prop);
    } 
 
    /** 
     * Removes a keystore from the persistence mechanism. 
     * @param keystoreFile 
     * @throws IOException 
     */ 
    public void removeEntry(File keystoreFile) throws IOException
    { 
        Properties properties = load();
        properties.remove(keystoreFile.getAbsolutePath());
        store(properties);
    } 
 
    /** 
     * Sets backup date from a keystore  
     * @param keystoreFile The keystore file. 
     * @param backupDate The date of the backup. 
     * @throws IOException If there are problems loading the persistence file. 
     */ 
    public void setBackupDate(File keystoreFile, Date backupDate) throws IOException
    { 
        ViewStateEntry entry = getEntry(keystoreFile);
        entry.setBackupDate(backupDate);
        addEntry(keystoreFile, entry);
    } 
 
    private Properties load() throws IOException
    { 
        FileInputStream in = null;
        Properties props = new Properties();
 
        try 
        { 
            in = new FileInputStream(persistenceFile);
            props.loadFromXML(in);
        } 
        finally 
        { 
            if (in != null)
            { 
                in.close();
            } 
        } 
        return props;
    } 
 
    private void store(Properties prop) throws IOException
    { 
        FileOutputStream out = null;
 
        try 
        { 
            out = new FileOutputStream(persistenceFile);
            prop.storeToXML(out, FILE_COMMENT);
        } 
        finally 
        { 
            if (out != null)
            {