Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-142

Add facility to sort file lists/arrays to Comparator implementations

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.4
    • 2.0
    • Utilities
    • None
    • Java SE 5 - Windows, Linux

    Description

      I searched your current Commons-IO issues/feature requests and did not find the following so I'd like to propose it as a feature request.

      Given a filename filter and dir name, the method would return a List<File> of the files that match the filter in last-modified timestamp order.

      Sun explicitly does not provide this functionality - from the Sun Java SE 5 API Javadocs, File's listFiles() method descriptions include the following disclaimer:
      "There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order."

      I needed the files in last-modified order so I wrote code to do it and would be glad to share the code with the commons project if you feel it would be useful.

      The signature is:

      • public List<File> getFileListInTimestampOrder(FilenameFilter filter, String dirName)

      I've already written, tested and used code to do this.

      There are additional flavors that might be worthwhile, too.

      • public List<File> getFileListInTimestampOrderReversed(FilenameFilter filter, String dirName)
      • public List<File> getFileListInNameOrder(FilenameFilter filter, String dirName)
      • public List<File> getFileListInNameOrderReversed(FilenameFilter filter, String dirName)

      BTW, I originally posted this on commons-lang but was given feedback that it might be a better fit here.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            niallp Niall Pemberton
            alscherer Al Scherer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment