title: How to list only N files in directory using java
body: <p>If I have a directory contains a lot of files (about 1000 file). Some of these files named <strong><em>.processed</em></strong> and other not.  </p>
  
  <p>How can I list only 10 unprocessed files. </p>
  
  <p>I am using this code to filter the processed file. </p>
  
  <pre><code>File[] inputFileList = inputDirectory.listFiles(new FileFilter() {
                  @Override
                  public boolean accept(File pathname) {
                      return !pathname.getName().endsWith(".processed");
                  }
              });
  </code></pre>
  
  <p>But if the number of un-processed files is huge, this may lead to memory error. so I need to read a limited number of files each time the application will run.</p>