List files sorted by date in java

File inboxDir = new File(“Path to your directory”);
File[] files = inboxDir.listFiles();
Arrays.sort( files, new Comparator()
{
public int compare(Object o1, Object o2) {
return new Long(((File)o1).lastModified()).compareTo(new Long(((File) o2).lastModified()));
}

});

One Response to “List files sorted by date in java”

Leave a Reply

*