title: error while using try with resources in Java
body: <p>I have this method where I am using try with resources of Java SE 7.</p>
  
  <pre><code>private void generateSecretWord(String filename){
  
          try (FileReader files = new FileReader(filename)){
              Scanner input = new Scanner(files);
              String line = input.nextLine();
              String[] words = line.split(",");
              Collections.shuffle(Arrays.asList(words));
              if (words[0].length()&gt;1){
                  secretWord = words[0];
                  return;
              }
  
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
          finally {
              if (files!=null) files.close(); 
          }
  
      }
  </code></pre>
  
  <p>I get compile error in <code>finally</code> block that <code>files cannot be resolved to a variable</code>
  I have reference for files in the <code>try with  block</code>. why do I get this error and how to fix it?</p>
  
  <p>Thanks</p>