Java tutorial
import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileTime; import java.util.Calendar; public class Test { public static void main(String[] args) throws Exception { Path path = Paths.get("C:/home/docs/users.txt"); BasicFileAttributeView view = Files.getFileAttributeView(path, BasicFileAttributeView.class); BasicFileAttributes attributes = view.readAttributes(); FileTime lastModifedTime = attributes.lastModifiedTime(); FileTime createTime = attributes.creationTime(); long currentTime = Calendar.getInstance().getTimeInMillis(); FileTime lastAccessTime = FileTime.fromMillis(currentTime); view.setTimes(lastModifedTime, lastAccessTime, createTime); System.out.println(attributes.lastAccessTime()); } }