安卓開發(fā)之文件夾以及文件排序
來源:易賢網(wǎng) 閱讀:1980 次 日期:2014-08-21 16:08:06
溫馨提示:易賢網(wǎng)小編為您整理了“安卓開發(fā)之文件夾以及文件排序”,方便廣大網(wǎng)友查閱!

static Comparator<File> comparator = new Comparator<File>() {

public int compare(File f1, File f2) {

if (f1 == null || f2 == null) {// 先比較null

if (f1 == null) {

{

return -1;

}

} else {

return 1;

}

} else {

if (f1.isDirectory() == true && f2.isDirectory() == true) { // 再比較文件夾

return f1.getName().compareToIgnoreCase(f2.getName());

} else {

if ((f1.isDirectory() && !f2.isDirectory()) == true) {

return -1;

} else if ((f2.isDirectory() && !f1.isDirectory()) == true) {

return 1;

} else {

return f1.getName().compareToIgnoreCase(f2.getName());// 最后比較文件

}

}

}

}

};

更多信息請查看IT技術專欄

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:安卓開發(fā)之文件夾以及文件排序
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)