title: Java FilenameFilter
body: <p>I have a requirement to get all of the files in a directory that have a specific extension(say, .txt).  I should be able to list all of the files that have '.txt' and '.TXT' extension (i.e., it should be case insensitive). I've written the following class for this.  What change should I make in the following class to achieve this?</p>
  
  <pre><code>class OnlyExt implements FilenameFilter {
      String ext;
  
      public OnlyExt(String ext) {
          this.ext = "." + ext;
      }
  
      public boolean accept(File dir, String name) {
          return name.endsWith(ext);
      }
  }
  </code></pre>
  
  <p>Well, I tried <code>name.toLowerCase().endsWith(ext);</code> in the <code>accept()</code>, but that didn't work.</p>
  
  <p>Thanks in advance.</p>