title: Getting files by lastmodified date
body: <p>What is the fastest way to get files by lastmodified date?
  I got a directory with some txt files. User can do a research by date, I list all files in the directory by lastmodified date (in File[]) and i search for the right file with the specific date.
  I use a collection sort using lastmodified date to sort my files. When I get files from my local drive it's fast but when i want to access to a drive on the netword (private network) it can take about 10 minutes to get a file. I know i can't be quicker than the network but is there a solution that can be really faster than my solution?</p>
  
  <p>exemple for my code :</p>
  
  <pre><code>File[] files = repertoire.listFiles();         
  
  Arrays.sort(files, new Comparator&lt;File&gt;() {
      @Override
      public int compare(File o1, File o2) {
          return Long.valueOf(o2.lastModified()).compareTo(o1.lastModified());
      }
  });
  
  for (File element : files) {
      // i get the right file;
  }
  </code></pre>
  
  <p>Thanks for your help</p>
  
  <p><strong>Here is the solution :</strong> </p>
  
  <pre><code>Path repertoiry = Paths.get(repertoire.getAbsolutePath());
  final DirectoryStream&lt;Path&gt; stream = Files.newDirectoryStream(repertoiry, new DirectoryStream.Filter&lt;Path&gt;() {
       @Override
       public boolean accept(Path entry) throws IOException {
            return Files.getLastModifiedTime(entry, LinkOption.NOFOLLOW_LINKS).toMillis() &gt;= (dateRechercheeA.getTime() - (24 * 60 * 60 * 1000)) &amp;&amp; Files.getLastModifiedTime(entry, LinkOption.NOFOLLOW_LINKS).toMillis() &lt;= (dateRechercheeB.getTime() + (24 * 60 * 60 * 1000));
       }
  });
  for (Path path : stream) {
       if (!path.toFile().getName().endsWith("TAM") &amp;&amp; !path.toFile().getName().endsWith("RAM")) {
           listFichiers.add(path.toFile());
       }
  }
  </code></pre>