Created
February 20, 2013 03:17
-
-
Save shaobin0604/4992547 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static final Comparator<File> FILE_COMPARATOR = new Comparator<File>() { | |
| @Override | |
| public int compare(File lhs, File rhs) { | |
| boolean ldir = lhs.isDirectory(); | |
| boolean rdir = rhs.isDirectory(); | |
| if (ldir == rdir) { | |
| // both are files or directories | |
| return lhs.getName().compareToIgnoreCase(rhs.getName()); | |
| } else if (ldir) { | |
| return -1; | |
| } else { | |
| return 1; | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment