Raj
Raj

Reputation: 51

Example of getLastModifiedTime() method in java.nio.*.

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

Answers (2)

Philippe Franklin
Philippe Franklin

Reputation: 201

Or directly:

File file = new File(...);
FileTime time = Files.getLastModifiedTime(file.toPath());

Upvotes: 3

Amit Deshpande
Amit Deshpande

Reputation: 19185

Path file = ...
BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
FileTime time = attrs.lastModifiedTime();

Java Doc BasicFileAttributes#lastModifiedTime

Upvotes: 7

Related Questions