@@ -35,11 +35,9 @@ <h3>Sorting</h3>
3535< p >
3636 ...alternatively you can do this in one line:
3737</ p >
38- < p >
39- < pre >
40- File[] files = NameFileComparator.NAME_COMPARATOR.sort(dir.listFiles());
41- </ pre >
42- </ p >
38+ < pre >
39+ File[] files = NameFileComparator.NAME_COMPARATOR.sort(dir.listFiles());
40+ </ pre >
4341
4442< h3 > Composite Comparator</ h3 >
4543< p >
@@ -50,139 +48,137 @@ <h3>Composite Comparator</h3>
5048 For example, to sort an array of files by type (i.e. directory or file)
5149 and then by name:
5250</ p >
53- < p >
54- < pre >
55- CompositeFileComparator comparator =
56- new CompositeFileComparator(
57- DirectoryFileComparator.DIRECTORY_COMPARATOR,
58- NameFileComparator.NAME_COMPARATOR);
59- File[] files = dir.listFiles();
60- comparator.sort(files);
61- </ pre >
62- </ p >
51+ < pre >
52+ CompositeFileComparator comparator =
53+ new CompositeFileComparator(
54+ DirectoryFileComparator.DIRECTORY_COMPARATOR,
55+ NameFileComparator.NAME_COMPARATOR);
56+ File[] files = dir.listFiles();
57+ comparator.sort(files);
58+ </ pre >
6359
6460< h3 > Singleton Instances (thread-safe)</ h3 >
6561< p >
6662 The {@link java.util.Comparator} implementations have some < i > convenience</ i >
6763 singleton(< i > thread-safe</ i > ) instances ready to use:
68- < ul >
69- < li > < a href ="DefaultFileComparator.html "> DefaultFileComparator</ a > - default file compare:
70- < ul >
71- < li > < a href ="DefaultFileComparator.html#DEFAULT_COMPARATOR "> DEFAULT_COMPARATOR</ a >
72- - Compare using < code > File.compareTo(File)</ code > method.
73- </ li >
74- < li > < a href ="DefaultFileComparator.html#DEFAULT_REVERSE "> DEFAULT_REVERSE</ a >
75- - Reverse compare of < code > File.compareTo(File)</ code > method.
76- </ li >
77- </ ul >
78- </ li >
79- < li > < a href ="DirectoryFileComparator.html "> DirectoryFileComparator</ a > - compare by type (directory or file):
80- < ul >
81- < li > < a href ="DirectoryFileComparator.html#DIRECTORY_COMPARATOR "> DIRECTORY_COMPARATOR</ a >
82- - Compare using < code > File.isDirectory()</ code > method (directories < files ).
83- </ li >
84- < li > < a href ="DirectoryFileComparator.html#DIRECTORY_REVERSE "> DIRECTORY_REVERSE</ a >
85- - Reverse compare of < code > File.isDirectory()</ code > method (directories > files).
86- </ li >
87- </ ul >
88- </ li >
89- < li > < a href ="ExtensionFileComparator.html "> ExtensionFileComparator</ a > - compare file extenstions:
90- < ul >
91- < li > < a href ="ExtensionFileComparator.html#EXTENSION_COMPARATOR "> EXTENSION_COMPARATOR</ a >
92- - Compare using < code > FilenameUtils.getExtension(String)</ code > method.
93- </ li >
94- < li > < a href ="ExtensionFileComparator.html#EXTENSION_REVERSE "> EXTENSION_REVERSE</ a >
95- - Reverse compare of < code > FilenameUtils.getExtension(String)</ code > method.
96- </ li >
97- < li > < a href ="ExtensionFileComparator.html#EXTENSION_INSENSITIVE_COMPARATOR "> EXTENSION_INSENSITIVE_COMPARATOR</ a >
98- - Case-insensitive compare using < code > FilenameUtils.getExtension(String)</ code > method.
99- </ li >
100- < li > < a href ="ExtensionFileComparator.html#EXTENSION_INSENSITIVE_REVERSE "> EXTENSION_INSENSITIVE_REVERSE</ a >
101- - Reverse case-insensitive compare of < code > FilenameUtils.getExtension(String)</ code > method.
102- </ li >
103- < li > < a href ="ExtensionFileComparator.html#EXTENSION_SYSTEM_COMPARATOR "> EXTENSION_SYSTEM_COMPARATOR</ a >
104- - System sensitive compare using < code > FilenameUtils.getExtension(String)</ code > method.
105- </ li >
106- < li > < a href ="ExtensionFileComparator.html#EXTENSION_SYSTEM_REVERSE "> EXTENSION_SYSTEM_REVERSE</ a >
107- - Reverse system sensitive compare of < code > FilenameUtils.getExtension(String)</ code > method.
108- </ li >
109- </ ul >
110- </ li >
111- < li > < a href ="LastModifiedFileComparator.html "> LastModifiedFileComparator</ a >
112- - compare the file's last modified date/time:
113- < ul >
114- < li > < a href ="LastModifiedFileComparator.html#LASTMODIFIED_COMPARATOR "> LASTMODIFIED_COMPARATOR</ a >
115- - Compare using < code > File.lastModified()</ code > method.
116- </ li >
117- < li > < a href ="LastModifiedFileComparator.html#LASTMODIFIED_REVERSE "> LASTMODIFIED_REVERSE</ a >
118- - Reverse compare of < code > File.lastModified()</ code > method.
119- </ li >
120- </ ul >
121- </ li >
122- < li > < a href ="NameFileComparator.html "> NameFileComparator</ a > - compare file names:
123- < ul >
124- < li > < a href ="NameFileComparator.html#NAME_COMPARATOR "> NAME_COMPARATOR</ a >
125- - Compare using < code > File.getName()</ code > method.
126- </ li >
127- < li > < a href ="NameFileComparator.html#NAME_REVERSE "> NAME_REVERSE</ a >
128- - Reverse compare of < code > File.getName()</ code > method.
129- </ li >
130- < li > < a href ="NameFileComparator.html#NAME_INSENSITIVE_COMPARATOR "> NAME_INSENSITIVE_COMPARATOR</ a >
131- - Case-insensitive compare using < code > File.getName()</ code > method.
132- </ li >
133- < li > < a href ="NameFileComparator.html#NAME_INSENSITIVE_REVERSE "> NAME_INSENSITIVE_REVERSE</ a >
134- - Reverse case-insensitive compare of < code > File.getName()</ code > method.
135- </ li >
136- < li > < a href ="NameFileComparator.html#NAME_SYSTEM_COMPARATOR "> NAME_SYSTEM_COMPARATOR</ a >
137- - System sensitive compare using < code > File.getName()</ code > method.
138- </ li >
139- < li > < a href ="NameFileComparator.html#NAME_SYSTEM_REVERSE "> NAME_SYSTEM_REVERSE</ a >
140- - Reverse system sensitive compare of < code > File.getName()</ code > method.
141- </ li >
142- </ ul >
143- </ li >
144- < li > < a href ="PathFileComparator.html "> PathFileComparator</ a > - compare file paths:
145- < ul >
146- < li > < a href ="PathFileComparator.html#PATH_COMPARATOR "> PATH_COMPARATOR</ a >
147- - Compare using < code > File.getPath()</ code > method.
148- </ li >
149- < li > < a href ="PathFileComparator.html#PATH_REVERSE "> PATH_REVERSE</ a >
150- - Reverse compare of < code > File.getPath()</ code > method.
151- </ li >
152- < li > < a href ="PathFileComparator.html#PATH_INSENSITIVE_COMPARATOR "> PATH_INSENSITIVE_COMPARATOR</ a >
153- - Case-insensitive compare using < code > File.getPath()</ code > method.
154- </ li >
155- < li > < a href ="PathFileComparator.html#PATH_INSENSITIVE_REVERSE "> PATH_INSENSITIVE_REVERSE</ a >
156- - Reverse case-insensitive compare of < code > File.getPath()</ code > method.
157- </ li >
158- < li > < a href ="PathFileComparator.html#PATH_SYSTEM_COMPARATOR "> PATH_SYSTEM_COMPARATOR</ a >
159- - System sensitive compare using < code > File.getPath()</ code > method.
160- </ li >
161- < li > < a href ="PathFileComparator.html#PATH_SYSTEM_REVERSE "> PATH_SYSTEM_REVERSE</ a >
162- - Reverse system sensitive compare of < code > File.getPath()</ code > method.
163- </ li >
164- </ ul >
165- </ li >
166- < li > < a href ="SizeFileComparator.html "> SizeFileComparator</ a > - compare the file's size:
167- < ul >
168- < li > < a href ="SizeFileComparator.html#SIZE_COMPARATOR "> SIZE_COMPARATOR</ a >
169- - Compare using < code > File.length()</ code > method (directories treated as zero length).
170- </ li >
171- < li > < a href ="SizeFileComparator.html#SIZE_REVERSE "> LASTMODIFIED_REVERSE</ a >
172- - Reverse compare of < code > File.length()</ code > method (directories treated as zero length).
173- </ li >
174- < li > < a href ="SizeFileComparator.html#SIZE_SUMDIR_COMPARATOR "> SIZE_SUMDIR_COMPARATOR</ a >
175- - Compare using < code > FileUtils.sizeOfDirectory(File)</ code > method
176- (sums the size of a directory's contents).
177- </ li >
178- < li > < a href ="SizeFileComparator.html#SIZE_SUMDIR_REVERSE "> SIZE_SUMDIR_REVERSE</ a >
179- - Reverse compare of < code > FileUtils.sizeOfDirectory(File)</ code > method
180- (sums the size of a directory's contents).
181- </ li >
182- </ ul >
183- </ li >
184- </ ul >
18564</ p >
65+ < ul >
66+ < li > < a href ="DefaultFileComparator.html "> DefaultFileComparator</ a > - default file compare:
67+ < ul >
68+ < li > < a href ="DefaultFileComparator.html#DEFAULT_COMPARATOR "> DEFAULT_COMPARATOR</ a >
69+ - Compare using < code > File.compareTo(File)</ code > method.
70+ </ li >
71+ < li > < a href ="DefaultFileComparator.html#DEFAULT_REVERSE "> DEFAULT_REVERSE</ a >
72+ - Reverse compare of < code > File.compareTo(File)</ code > method.
73+ </ li >
74+ </ ul >
75+ </ li >
76+ < li > < a href ="DirectoryFileComparator.html "> DirectoryFileComparator</ a > - compare by type (directory or file):
77+ < ul >
78+ < li > < a href ="DirectoryFileComparator.html#DIRECTORY_COMPARATOR "> DIRECTORY_COMPARATOR</ a >
79+ - Compare using < code > File.isDirectory()</ code > method (directories < files).
80+ </ li >
81+ < li > < a href ="DirectoryFileComparator.html#DIRECTORY_REVERSE "> DIRECTORY_REVERSE</ a >
82+ - Reverse compare of < code > File.isDirectory()</ code > method (directories >files).
83+ </ li >
84+ </ ul >
85+ </ li >
86+ < li > < a href ="ExtensionFileComparator.html "> ExtensionFileComparator</ a > - compare file extenstions:
87+ < ul >
88+ < li > < a href ="ExtensionFileComparator.html#EXTENSION_COMPARATOR "> EXTENSION_COMPARATOR</ a >
89+ - Compare using < code > FilenameUtils.getExtension(String)</ code > method.
90+ </ li >
91+ < li > < a href ="ExtensionFileComparator.html#EXTENSION_REVERSE "> EXTENSION_REVERSE</ a >
92+ - Reverse compare of < code > FilenameUtils.getExtension(String)</ code > method.
93+ </ li >
94+ < li > < a href ="ExtensionFileComparator.html#EXTENSION_INSENSITIVE_COMPARATOR "> EXTENSION_INSENSITIVE_COMPARATOR</ a >
95+ - Case-insensitive compare using < code > FilenameUtils.getExtension(String)</ code > method.
96+ </ li >
97+ < li > < a href ="ExtensionFileComparator.html#EXTENSION_INSENSITIVE_REVERSE "> EXTENSION_INSENSITIVE_REVERSE</ a >
98+ - Reverse case-insensitive compare of < code > FilenameUtils.getExtension(String)</ code > method.
99+ </ li >
100+ < li > < a href ="ExtensionFileComparator.html#EXTENSION_SYSTEM_COMPARATOR "> EXTENSION_SYSTEM_COMPARATOR</ a >
101+ - System sensitive compare using < code > FilenameUtils.getExtension(String)</ code > method.
102+ </ li >
103+ < li > < a href ="ExtensionFileComparator.html#EXTENSION_SYSTEM_REVERSE "> EXTENSION_SYSTEM_REVERSE</ a >
104+ - Reverse system sensitive compare of < code > FilenameUtils.getExtension(String)</ code > method.
105+ </ li >
106+ </ ul >
107+ </ li >
108+ < li > < a href ="LastModifiedFileComparator.html "> LastModifiedFileComparator</ a >
109+ - compare the file's last modified date/time:
110+ < ul >
111+ < li > < a href ="LastModifiedFileComparator.html#LASTMODIFIED_COMPARATOR "> LASTMODIFIED_COMPARATOR</ a >
112+ - Compare using < code > File.lastModified()</ code > method.
113+ </ li >
114+ < li > < a href ="LastModifiedFileComparator.html#LASTMODIFIED_REVERSE "> LASTMODIFIED_REVERSE</ a >
115+ - Reverse compare of < code > File.lastModified()</ code > method.
116+ </ li >
117+ </ ul >
118+ </ li >
119+ < li > < a href ="NameFileComparator.html "> NameFileComparator</ a > - compare file names:
120+ < ul >
121+ < li > < a href ="NameFileComparator.html#NAME_COMPARATOR "> NAME_COMPARATOR</ a >
122+ - Compare using < code > File.getName()</ code > method.
123+ </ li >
124+ < li > < a href ="NameFileComparator.html#NAME_REVERSE "> NAME_REVERSE</ a >
125+ - Reverse compare of < code > File.getName()</ code > method.
126+ </ li >
127+ < li > < a href ="NameFileComparator.html#NAME_INSENSITIVE_COMPARATOR "> NAME_INSENSITIVE_COMPARATOR</ a >
128+ - Case-insensitive compare using < code > File.getName()</ code > method.
129+ </ li >
130+ < li > < a href ="NameFileComparator.html#NAME_INSENSITIVE_REVERSE "> NAME_INSENSITIVE_REVERSE</ a >
131+ - Reverse case-insensitive compare of < code > File.getName()</ code > method.
132+ </ li >
133+ < li > < a href ="NameFileComparator.html#NAME_SYSTEM_COMPARATOR "> NAME_SYSTEM_COMPARATOR</ a >
134+ - System sensitive compare using < code > File.getName()</ code > method.
135+ </ li >
136+ < li > < a href ="NameFileComparator.html#NAME_SYSTEM_REVERSE "> NAME_SYSTEM_REVERSE</ a >
137+ - Reverse system sensitive compare of < code > File.getName()</ code > method.
138+ </ li >
139+ </ ul >
140+ </ li >
141+ < li > < a href ="PathFileComparator.html "> PathFileComparator</ a > - compare file paths:
142+ < ul >
143+ < li > < a href ="PathFileComparator.html#PATH_COMPARATOR "> PATH_COMPARATOR</ a >
144+ - Compare using < code > File.getPath()</ code > method.
145+ </ li >
146+ < li > < a href ="PathFileComparator.html#PATH_REVERSE "> PATH_REVERSE</ a >
147+ - Reverse compare of < code > File.getPath()</ code > method.
148+ </ li >
149+ < li > < a href ="PathFileComparator.html#PATH_INSENSITIVE_COMPARATOR "> PATH_INSENSITIVE_COMPARATOR</ a >
150+ - Case-insensitive compare using < code > File.getPath()</ code > method.
151+ </ li >
152+ < li > < a href ="PathFileComparator.html#PATH_INSENSITIVE_REVERSE "> PATH_INSENSITIVE_REVERSE</ a >
153+ - Reverse case-insensitive compare of < code > File.getPath()</ code > method.
154+ </ li >
155+ < li > < a href ="PathFileComparator.html#PATH_SYSTEM_COMPARATOR "> PATH_SYSTEM_COMPARATOR</ a >
156+ - System sensitive compare using < code > File.getPath()</ code > method.
157+ </ li >
158+ < li > < a href ="PathFileComparator.html#PATH_SYSTEM_REVERSE "> PATH_SYSTEM_REVERSE</ a >
159+ - Reverse system sensitive compare of < code > File.getPath()</ code > method.
160+ </ li >
161+ </ ul >
162+ </ li >
163+ < li > < a href ="SizeFileComparator.html "> SizeFileComparator</ a > - compare the file's size:
164+ < ul >
165+ < li > < a href ="SizeFileComparator.html#SIZE_COMPARATOR "> SIZE_COMPARATOR</ a >
166+ - Compare using < code > File.length()</ code > method (directories treated as zero length).
167+ </ li >
168+ < li > < a href ="SizeFileComparator.html#SIZE_REVERSE "> LASTMODIFIED_REVERSE</ a >
169+ - Reverse compare of < code > File.length()</ code > method (directories treated as zero length).
170+ </ li >
171+ < li > < a href ="SizeFileComparator.html#SIZE_SUMDIR_COMPARATOR "> SIZE_SUMDIR_COMPARATOR</ a >
172+ - Compare using < code > FileUtils.sizeOfDirectory(File)</ code > method
173+ (sums the size of a directory's contents).
174+ </ li >
175+ < li > < a href ="SizeFileComparator.html#SIZE_SUMDIR_REVERSE "> SIZE_SUMDIR_REVERSE</ a >
176+ - Reverse compare of < code > FileUtils.sizeOfDirectory(File)</ code > method
177+ (sums the size of a directory's contents).
178+ </ li >
179+ </ ul >
180+ </ li >
181+ </ ul >
186182
187183</ body >
188184</ html >
0 commit comments