fix. в методе keepnewFiles была индийская сортировка. вместо Long.compare было приведение к инту и сравнение. что вызывало исключение.
This commit is contained in:
@@ -1013,13 +1013,14 @@ public class Utils {
|
||||
public static int fromBoolean(boolean flag) {
|
||||
return flag ? 1 : 0;
|
||||
}
|
||||
|
||||
public static void keepNewFiles(File directory, int count) throws Exception {
|
||||
if (count > 0) {
|
||||
File[] old_ = directory.listFiles(pathname -> pathname.isFile());
|
||||
if (old_ != null) {
|
||||
Vector<File> old = new Vector<>();
|
||||
Collections.addAll(old, old_);
|
||||
old.sort((o1, o2) -> (int) (o2.lastModified() - o1.lastModified()));
|
||||
old.sort((o1, o2) -> Long.compare(o2.lastModified(), o1.lastModified()));
|
||||
for (int i = count - 1; i < old.size(); ++i) {
|
||||
File file = old.get(i);
|
||||
System.out.println(file.getName() + ":" + file.lastModified());
|
||||
|
||||
Reference in New Issue
Block a user