public class CompositeFileComparator extends AbstractFileComparator implements Serializable
Comparator.
This comparator can be used to sort lists or arrays of files by combining a number of other comparators.
Example of sorting a list of files by type (directory or file) and then by name:
CompositeFileComparator comparator = new CompositeFileComparator(
DirectoryFileComparator.DIRECTORY_COMPARATOR,
NameFileComparator.NAME_COMPARATOR);
List<File> list = ...
comparator.sort(list);
Serialization is deprecated and will be removed in 3.0.
| Constructor and Description |
|---|
CompositeFileComparator(Comparator<File>... delegates)
Constructs a composite comparator for the set of delegate comparators.
|
CompositeFileComparator(Iterable<Comparator<File>> delegates)
Constructs a composite comparator for the set of delegate comparators.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(File file1,
File file2)
Compares the two files using delegate comparators.
|
String |
toString()
String representation of this file comparator.
|
sort, sortclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic CompositeFileComparator(Comparator<File>... delegates)
delegates - The delegate file comparatorspublic CompositeFileComparator(Iterable<Comparator<File>> delegates)
delegates - The delegate file comparatorspublic int compare(File file1, File file2)
compare in interface Comparator<File>file1 - The first file to comparefile2 - The second file to comparepublic String toString()
toString in class AbstractFileComparator