public class FileNameComparator
extends java.lang.Object
implements java.util.Comparator<java.lang.Object>
FileNameComparator implements a Comparator class that compares file names (expressed either as String or File objects) for sorting. The comparison can be case-sensitive or case-insensitive, and can apply to the entire path (if available) or just the file name part.
Constructor and Description |
---|
FileNameComparator()
Construct a new FileNameComparator with the default settings.
|
FileNameComparator(boolean foldCase,
boolean entirePath)
Construct a new FileNameComparator.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Compares its two arguments for order.
|
boolean |
equals(java.lang.Object o)
Indicates whether some other object is "equal to" this
Comparator.
|
int |
hashCode()
Get the hash code for this object.
|
public FileNameComparator()
Comparator cmp = new FileNameComparator (false, false);
public FileNameComparator(boolean foldCase, boolean entirePath)
foldCase
- true for case-insensitive comparison,
false for case-sensitive comparisonentirePath
- true to compare the entire path (where
available, false to use just the name.public int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator<java.lang.Object>
o1
- the first object to be comparedo2
- the second object to be comparedpublic boolean equals(java.lang.Object o)
Indicates whether some other object is "equal to" this Comparator.
equals
in interface java.util.Comparator<java.lang.Object>
equals
in class java.lang.Object
o
- the object to comparepublic int hashCode()
hashCode
in class java.lang.Object