直接获取File的最新修改的时间值,然后做个比较。
List<File> asList = Arrays.asList(new File(PathHelper.PATH_PROJECT_PIC)
.listFiles());
Collections.reverse(asList);
Integer[] a = {
1
,
3
,
5
,
7
,
9
};
Arrays.sort(a,
new
Comparator<Integer>() {
public
int
compare(Integer o1, Integer o2) {
return
o2 - o1;
}
});
System.out.println(Arrays.toString(a));
String[] a={
"5"
,
"6"
,
"7"
,
"9"
,
"4"
,
"1"
,
"2"
};
Arrays.sort(a,
new
Comparator<String>() {
public
int
compare(String o1, String o2) {
return
o2.charAt(
0
)-o1.charAt(
0
);
}
});
System.out.println(Arrays.toString(a));
String[] a={
"5"
,
"6"
,
"7"
,
"9"
,
"4"
,
"1"
,
"2"
};
Arrays.sort(a,
new
Comparator<String>() {
public
int
compare(String o1, String o2) {
return
o2.charAt(
0
)-o1.charAt(
0
);
}
});
System.out.println(Arrays.toString(a));
有任何疑问或技术合作都可联系我
微信:yanfahezuo 【推荐】
QQ:596957738