Compare the length/size of two files for order (see
{@link File#length()} and {@link FileUtils#sizeOfDirectory(File)}).
This comparator can be used to sort lists or arrays of files
by their length/size.
Example of sorting a list of files using the
{@link #SIZE_COMPARATOR} singleton instance:
List<File> list = ...
Collections.sort(list, LengthFileComparator.LENGTH_COMPARATOR);
Example of doing a reverse sort of an array of files using the
{@link #SIZE_REVERSE} singleton instance:
File[] array = ...
Arrays.sort(array, LengthFileComparator.LENGTH_REVERSE);
N.B. Directories are treated as zero size unless
sumDirectoryContents is true . |