Is there a way in java to set the access time without setting the date modified time as well?
This will be in essence a touch -a command.
the setLastModified method in File updates both the access time as well as the date modified.
We are currently using java 6. Moving to 7 wouldn’t be out of the question.
You can use
Files.setAttribute()from Java 7:The string
"lastAccessTime"can be found in the description of theBasicFileAttributeView, which also provides an alternative way to set this property (together withFiles.getFileAttributeView()):I’m not aware of any pure Java way that works in Java 6 or earlier.