?? newerfilefirst.java
字號:
/**
*
*/
package org.codehaus.classloader;
import java.io.File;
import java.util.Comparator;
class NewerFileFirst implements Comparator{
private NewerFileFirst(){}
private static final NewerFileFirst singleton = new NewerFileFirst();
public static Comparator instance(){
return singleton;
}
private int compareTime(File f1, File f2){
long ts1 = f1.lastModified();
long ts2 = f2.lastModified();
if(ts1<ts2){
//newer file first
return 1;
}
else if(ts1>ts2){
//newer file first
return -1;
}
else{
return f1.getName().compareTo(f2.getName());
}
}
public int compare(Object arg1, Object arg2) {
final File f1 = (File)arg1;
final File f2 = (File)arg2;
if(f1.isDirectory()){
if(f2.isDirectory()){
return compareTime(f1, f2);
}
else{
//file first.
return 1;
}
}
else{
if(f2.isDirectory()){
//file first
return -1;
}
else{
return compareTime(f1, f2);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -