List of usage examples for java.nio.file Files setAttribute
public static Path setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { Path path = Paths.get("C:/tutorial/Java/JavaFX", "Topic.txt"); long time = System.currentTimeMillis(); FileTime fileTime = FileTime.fromMillis(time); try {/*from w w w . ja v a 2s . c om*/ Files.setAttribute(path, "basic:lastModifiedTime", fileTime, LinkOption.NOFOLLOW_LINKS); Files.setAttribute(path, "basic:creationTime", fileTime, LinkOption.NOFOLLOW_LINKS); Files.setAttribute(path, "basic:lastAccessTime", fileTime, LinkOption.NOFOLLOW_LINKS); } catch (IOException e) { System.err.println(e); } }