title: Groovy: Cannot cast object 'true' with class 'java.lang.Boolean' to class 'java.io.File'
body: <p>I don't understand why I am getting the following error. Any thoughts?</p>
  
  <p>I am getting error: </p>
  
  <p><code>Cannot cast object 'true' with class 'java.lang.Boolean' to class 'java.io.File'</code></p>
  
  <p>This is the code producing the error at line 'if (envProp.exists()...':</p>
  
  <pre><code>static private File envProp = new File('env.properties')
  static private File envPropBak = new File('env.properties.bak')
  
  @BeforeClass
  static void beforeAll() {
      if (envProp.exists()) {
          envPropBak.write( envProp.text )
      }
  }
  </code></pre>
  
  <p>I don't understand why <code>envProp.exists()</code> is trying to cast anything as another object. Method <code>.exists()</code> should just return a <code>boolean</code>.</p>
  
  <p>Thanks</p>