title: groovy read a file, resolve variables in file content
body: <p>I am new to Groovy and I could not get around this issue. I appreciate any help.</p>
  
  <p>I want to read a file from Groovy. While I am reading the content, for each line I want to substitute the string '${random_id}' and '${entryAuthor}' with different string values.</p>
  
  <pre><code>protected def doPost(String url, URL bodyFile, Map headers = new HashMap() ) {
      StringBuffer sb = new StringBuffer()
      def randomId = getRandomId()
      bodyFile.eachLine { line -&gt;
          sb.append( line.replace("\u0024\u007Brandom_id\u007D", randomId)
                       .replace("\u0024\u007BentryAuthor\u007D", entryAuthor) )
          sb.append("\n")
      }
      return doPost(url, sb.toString())
  }
  </code></pre>
  
  <p>But I got the following error:</p>
  
  <pre><code>groovy.lang.MissingPropertyException: 
  No such property: random_id for class: tests.SimplePostTest
  Possible solutions: randomId
      at foo.test.framework.FooTest.doPost_closure1(FooTest.groovy:85)
      at groovy.lang.Closure.call(Closure.java:411)
      at groovy.lang.Closure.call(Closure.java:427)
      at foo.test.framework.FooTest.doPost(FooTest.groovy:83)
      at foo.test.framework.FooTest.doPost(FooTest.groovy:80)
      at tests.SimplePostTest.Post &amp; check Entry ID(SimplePostTest.groovy:42)
  </code></pre>
  
  <p>Why would it complain about a property, when I am not doing anything? I also tried "\$\{random_id\}", which works in Java String.replace(), but not in Groovy. </p>