Ejemplo n.º 1
0
 @Override
 protected boolean onInitialise() {
   m_oProperties = new Properties();
   // Attempt to read in the properties file
   if (m_oPropertiesFile.exists()) {
     FileInputStream loInput = null;
     try {
       loInput = new FileInputStream(m_oPropertiesFile);
       m_oProperties.load(loInput);
     } catch (FileNotFoundException ex) {
       // This should not be possible as we first checked if the file exists
     } catch (IOException ex) {
       // Properties could not be loaded, report the exception.  This may mean the properties
       // file has been corrupted, for now leave alone and just use the default values
       Application.log(ex);
       m_oProperties = new Properties();
     } finally {
       if (loInput != null) {
         try {
           loInput.close();
         } catch (IOException ex) {
           // Do nothing here
         }
       }
     }
   }
   return true;
 }
Ejemplo n.º 2
0
 @Override
 protected boolean onWriteProperties() {
   FileOutputStream loOutput = null;
   try {
     // Ensure the file exists
     if (!m_oPropertiesFile.getParentFile().exists()) {
       m_oPropertiesFile.getParentFile().mkdirs();
     }
     // Ignore the result because it just means the file may already exist
     m_oPropertiesFile.createNewFile();
     loOutput = new FileOutputStream(m_oPropertiesFile);
     m_oProperties.store(loOutput, "");
     return true;
   } catch (IOException ex) {
     Application.log(ex);
   } finally {
     if (loOutput != null) {
       try {
         loOutput.close();
       } catch (IOException ex) {
         // Do nothing here
       }
     }
   }
   return false;
 }