I'm reading Oracle documentation and encountered something that looks like an error to me.
Perhaps someone can confirm, or explain it better than the documentation.
Source: https://docs.oracle.com/javase/tutorial/essential/io/fileAttr.html
Code:
Path file = ...;
BasicFileAttributes attr =
Files.readAttributes(file, BasicFileAttributes.class);
long currentTime = System.currentTimeMillis();
FileTime ft = FileTime.fromMillis(currentTime);
Files.setLastModifiedTime(file, ft);
Should not setLastModifiedTime()
be called on attr
instead of Files
? (attr.setLastModifiedTime(file, ft)
)
If not, why is attr
needed at all?