org.apache.commons.io.comparator
public class LastModifiedFileComparator extends java.lang.Object implements java.util.Comparator, java.io.Serializable
File.lastModified()
).
This comparator can be used to sort lists or arrays of files by their last modified date/time.
Example of sorting a list of files using the
LASTMODIFIED_COMPARATOR
singleton instance:
List<File> list = ... Collections.sort(list, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);
Example of doing a reverse sort of an array of files using the
LASTMODIFIED_REVERSE
singleton instance:
File[] array = ... Arrays.sort(array, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator |
LASTMODIFIED_COMPARATOR
Last modified comparator instance
|
static java.util.Comparator |
LASTMODIFIED_REVERSE
Reverse last modified comparator instance
|
Constructor and Description |
---|
LastModifiedFileComparator() |
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object obj1,
java.lang.Object obj2)
Compare the last the last modified date/time of two files.
|
public static final java.util.Comparator LASTMODIFIED_COMPARATOR
public static final java.util.Comparator LASTMODIFIED_REVERSE
public int compare(java.lang.Object obj1, java.lang.Object obj2)
compare
in interface java.util.Comparator
obj1
- The first file to compareobj2
- The second file to compareCopyright (c) 2002-2015 Apache Software Foundation