import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.util.ArrayList;
import java.util.List; public class Main { public static void main(String[] args) { try { Path startingDir = Paths.get("你的目录"); listFiles(startingDir); } catch (IOException e) { e.printStackTrace(); } } public static void listFiles(Path dir) throws IOException { Files.walk(dir) .filter(Files::isRegularFile) .forEach(path -> { try { BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class); System.out.println("文件名: " + path.getFileName()); System.out.println("文件大小: " + attrs.size()); System.out.println("创建时间: " + attrs.creationTime()); } catch (IOException e) { e.printStackTrace(); } }); }
}