title: Listing only files in directory
body: <p>I have a folder with following structure</p>
  <pre><code>C:/rootDir/
  
  rootDir has following files
  
  test1.xml
  test2.xml
  test3.xml
  testDirectory &lt;------- This is a subdirectory inside rootDir
  </code></pre>
  <p>I'm only interested in the XML files inside rootDir because if I use JDOM to read the XML, the following code also considers the files inside <code>testDirectory</code> and spits out <code>content not allowed exception</code></p>
  <pre><code>File testDirectory = new File(&quot;C://rootDir//&quot;);
  File[] files = testDirectory.listFiles();
  </code></pre>
  <p>How can I exclude the subdirectory while using the <code>listFiles</code> method? Will the following code work?</p>
  <pre><code>File testDirectory = new File(&quot;C://rootDir//&quot;);
  File[] files = testDirectory.listFiles(new FilenameFilter() {
      
      @Override
      public boolean accept(File dir, String name) {
          return name.toLowerCase().endsWith(&quot;.xml&quot;);
      }
  });
  </code></pre>