Browse Source

Get the file list sorted in descending order

pull/78/head
kl 2 years ago
parent
commit
f13cccf5a6
  1. 4
      server/src/main/java/cn/keking/web/controller/FileController.java

4
server/src/main/java/cn/keking/web/controller/FileController.java

@ -119,7 +119,9 @@ public class FileController {
List<Map<String, String>> list = new ArrayList<>();
File file = new File(fileDir + demoPath);
if (file.exists()) {
Arrays.stream(Objects.requireNonNull(file.listFiles())).forEach(file1 -> {
File[] files = Objects.requireNonNull(file.listFiles());
Arrays.sort(files, (f1, f2) -> Long.compare(f2.lastModified(), f1.lastModified()));
Arrays.stream(files).forEach(file1 -> {
Map<String, String> fileName = new HashMap<>();
fileName.put("fileName", demoDir + "/" + file1.getName());
list.add(fileName);

Loading…
Cancel
Save