OK so w/o generics this is what I would have done (and it works)
But this code using generics blows up on me.
Note: Had to change the generic parameters to something like [file> instead of angle brackets on both sides 'cos fusetalk throws a hissy fit
The error I get is:
Any ideas?
File[] files = ...;
Comparator fileDtComparator = new Comparator() {
public int compare(Object o1, Object o2) {
if (!(o1 instanceof File))
return 0;
if (!(o2 instanceof File))
return 0;
File f1 = (File) o1;
File f2 = (File) o2;
long t = f1.lastModified() - f2.lastModified();
if (t > 0)
return 1;
if (t == 0)
return 0;
return -1;
}
};
Arrays.sort(files, fileDtComparator);
But this code using generics blows up on me.
Note: Had to change the generic parameters to something like [file> instead of angle brackets on both sides 'cos fusetalk throws a hissy fit
Comparator[File> fileDtComparator = new Comparator[File>() {
public int compare(File f1, File f2) {
long t = f1.lastModified() - f2.lastModified();
if (t > 0)
return 1;
if (t == 0)
return 0;
return -1;
}
};
Arrays.sort(files, fileDtComparator);
The error I get is:
Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: harris.sal.displays.FileLoggingDisplay$2.compare(Ljava/lang/Object;Ljava/lang/O
jectI
at java.util.Arrays.mergeSort(Arrays.java:1284)
at java.util.Arrays.mergeSort(Arrays.java:1295)
at java.util.Arrays.mergeSort(Arrays.java:1295)
at java.util.Arrays.mergeSort(Arrays.java:1295)
at java.util.Arrays.mergeSort(Arrays.java:1295)
at java.util.Arrays.mergeSort(Arrays.java:1295)
at java.util.Arrays.sort(Arrays.java:1223)
at harris.sal.displays.FileLoggingDisplay.cleanUpLogFolder(FileLoggingDisplay.java:602)
//more stuff below... prbly unrelated.
Any ideas?