SHARE
TWEET

StackOverflow Q 54357098

a guest Jan 25th, 2019 158 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function updatePropFile(string propFile, struct propStruct, struct removeStruct){
  2.         var key = "";
  3.         var value = "";
  4.         var config = "";
  5.        
  6.         // create empty object
  7.         config = createObject("java","org.apache.commons.configuration.PropertiesConfiguration").init();
  8.        
  9.         // load from given file path
  10.         config.setPath(arguments.propFile);
  11.         config.load();
  12.        
  13.         // append new properties
  14.         for(key in arguments.propStruct){
  15.             if(config.containsKey(key)){
  16.                 config.setProperty(key, arguments.propStruct[key]);
  17.             }else{
  18.                 config.addProperty(key, arguments.propStruct[key]);
  19.             }
  20.         }
  21.  
  22.         // clear prop and add as comment
  23.         for(key in arguments.removeStruct){
  24.             if(config.containsKey(key)){
  25.                 value = config.getProperty(key).toString();
  26.                 config.clearProperty(key);
  27.                 config.addProperty('##'&key, key & "=" & value);
  28.             }
  29.         }
  30.        
  31.         // save to file
  32.         config.save();
  33.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top