Is there an easy way to discover a File\'s creation time with Java? The File class only has a method to get the \"last modified\" time. According to some resources I found
This is a basic example in Java
, using BasicFileAttributes class:
Path path = Paths.get("C:\\Users\\jorgesys\\workspaceJava\\myfile.txt");
BasicFileAttributes attr;
try {
attr = Files.readAttributes(path, BasicFileAttributes.class);
System.out.println("File creation time: " + attr.creationTime());
} catch (IOException e) {
System.out.println("oops un error! " + e.getMessage());
}