Path paths = Paths.get(“路径”);
BasicFileAttributeView basicview = Files.getFileAttributeView(paths, BasicFileAttributeView.class,
LinkOption.NOFOLLOW_LINKS);
BasicFileAttributes attr = basicview.readAttributes();
#修改时间#
Date lastmodfiyTimeDate=new Date(attr.lastModifiedTime().toMillis());
#创建时间#
Date CreateTimeDate= new Date(attr.creationTime().toMillis());
System.out.println(lastmodfiyTimeDate);
System.out.println(CreateTimeDate);
获取文件创建时间和修改时间
最新推荐文章于 2024-07-03 17:21:01 发布