Reputation: 51
In Java 1.7, I'd read there are direct method to get last modified time of a file but I cant figure out what values should i pass to the parameters of LinkOptions. I'd appreciate the Most Simple Example. Thank You!
Upvotes: 4
Views: 4681
Reputation: 201
Or directly:
File file = new File(...);
FileTime time = Files.getLastModifiedTime(file.toPath());
Upvotes: 3
Reputation: 19185
Path file = ...
BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
FileTime time = attrs.lastModifiedTime();
Java Doc BasicFileAttributes#lastModifiedTime
Upvotes: 7