public int compare(Object o1, Object o2) {
File file1 = (File)o1;
File file2 = (File)o2;
long diff = file1.lastModified() - file2.lastModified();
if (diff > 0)
return 1;
else if (diff == 0)
return 0;
else
return -1;
}
public boolean equals(Object obj){
return true; //简单做法
}
java实现按照文件的修改时间排序文件夹下的文件
最新推荐文章于 2024-08-12 02:09:08 发布