1 package com.laurdawn;
 2 
 3 import java.io.File;
 4 import java.util.Date;
 5 
 6 public class Test {
 7 
 8     public static void main(String[] args) {
 9         // TODO Auto-generated method stub
10         WorkSpace();
11     }
12 
13     public static void WorkSpace() {
14         File f = new File("C:/Users/Administrator/Desktop/");
15         File[] array = f.listFiles();
16         for (int j = 1; j < array.length; j++) {
17             for (int i = 1; i < array.length; i++) {
18                 Date x = new Date(array[i].lastModified());
19                 Date y = new Date(array[i - 1].lastModified());
20                 if (x.after(y)) {
21                     File temp = array[i - 1];
22                     array[i - 1] = array[i];
23                     array[i] = temp;
24                 }
25             }
26         }
27         for (File n : array) {
28             Date d = new Date(n.lastModified());
29             System.out.print("文件名:" + n.getName());
30             System.out.print(";    文件大小:" + n.length() + "字节;");
31             System.out.println("    最近修改日期:" + d);
32         }
33     }
34 
35 }

 

相关文章:

  • 2021-12-23
  • 2021-06-23
  • 2022-12-23
  • 2021-12-23
  • 2021-11-16
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2021-12-13
  • 2022-03-10
相关资源
相似解决方案