获取文件创建时间和修改时间

					
					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);

你可能感兴趣的:(java,获取文件时间)