public void initProperties ( ) { propertiesPath = getContext ( ) . getFiles ( ) . getPropertiesLocation ( ) + File . separator + getContext ( ) . getAddOns ( ) . getAddOn ( ) . getID ( ) + ".properties" ; this . propertiesFile = new File ( propertiesPath ) ; if ( ! this . propertiesFile . exists ( ) ) try { this . propertiesFile . createNewFile ( ) ; } catch ( IOException e ) { error ( "Error while trying to create the new Properties file" , e ) ; } try { BufferedReader in = new BufferedReader ( new InputStreamReader ( new FileInputStream ( this . propertiesFile ) , "UTF8" ) ) ; try { properties . load ( in ) ; } catch ( IOException e ) { error ( "unable to load the InputStream for the PropertiesFile" , e ) ; } } catch ( FileNotFoundException | UnsupportedEncodingException e ) { error ( "Error while trying to read Properties-File" , e ) ; } if ( defaultPropertiesPath != null && new File ( defaultPropertiesPath ) . exists ( ) ) { @ SuppressWarnings ( "unchecked" ) Enumeration < String > keys = ( Enumeration < String > ) properties . propertyNames ( ) ; if ( ! keys . hasMoreElements ( ) ) { try { createDefaultPropertyFile ( defaultPropertiesPath ) ; } catch ( IOException e ) { error ( "Error while trying to copy the Default-Properties File" , e ) ; } if ( new File ( defaultPropertiesPath ) . exists ( ) && ! writeToPropertiesFile ( defaultPropertiesPath ) ) return ; reloadProperties ( ) ; } } }
Initializes properties in the addOn . Creates new properties file using default properties .