How to get file last modified date in Java
In Java, we can use Files.readAttributes() to get the file metadata or attribute, and then lastModifiedTime() to display the last modified date of a file. Path file = Paths.get("/home/mkyong/file.txt"); BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class); System.out.println("lastModifiedTime: " + attr.lastModifiedTime()); 1. BasicFileAttributes (NIO) This example uses the java.nio.* to display the file attributes or metadata – creation …