title: Get values from properties file using Groovy
body: <p>How to get values from properties file using Groovy?</p>
  
  <p>I require to have a property file (.properties) which would have file names as key, and their destination path as the value. I will need the key to be resolved at runtime, depending on file that needs to be moved. </p>
  
  <p>So far I am able to load the properties it seems but can't "get" the value from the loaded properties.</p>
  
  <p>I referred to the thread : <a href="https://stackoverflow.com/questions/2055959/groovy-how-to-access-to-properties-file">groovy: How to access to properties file?</a> and following is the code snippet i have so far </p>
  
  <pre><code>def  props = new Properties();
  File propFile = 
            new File('D:/XX/XX_Batch/XX_BATCH_COMMON/src/main/resources/patchFiles.properties')
  props.load(propFile.newDataInputStream())
  def config = new ConfigSlurper().parse(props)
      def ant = new AntBuilder()
      def list = ant.fileScanner {
                  fileset(dir:getSrcPath()) {
                      include(name:"**/*")
                  }
      }
      for (f in list) {
         def key = f.name
         println(props)
         println(config[key])
         println(config)
         def destn = new File(config['a'])
  
      }
  </code></pre>
  
  <p>the properties file has the following entries for now : </p>
  
  <pre><code>jan-feb-mar.jsp=/XX/Test/1
  XX-1.0.0-SNAPSHOT.jar=/XX/Test/1
  a=b
  c=d
  </code></pre>
  
  <p>Correct values are returned if I look up using either props.getProperty('a')
  or,
  config['a']
  Also tried the code: notation</p>
  
  <p>But as soon as switch to using the variable "key", as in config[key] it returns --> [:]</p>
  
  <p>I am new to groovy, can't say what am i missing here.</p>