Created
August 14, 2013 07:56
-
-
Save onecoders/6228854 to your computer and use it in GitHub Desktop.
file sort
This file contains 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 class SortFileName implements Comparator<File> { | |
@Override | |
public int compare(File f1, File f2) { | |
return f1.getName().compareToIgnoreCase(f2.getName()); | |
} | |
} | |
private class SortFolder implements Comparator<File> { | |
@Override | |
public int compare(File f1, File f2) { | |
if ((f1.isDirectory() && f2.isDirectory()) | |
|| (!f1.isDirectory() && !f2.isDirectory())) | |
return 0; | |
else if (f1.isDirectory() && !f2.isDirectory()) | |
return -1; | |
else | |
return 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment