As a continuation of this question - since it relates specifically to the time of creation and discusses its receipt through the new nio classes - it seems that now you are out of luck in the JDK7 implementation. Application: same behavior in OpenJDK7.
On Unix file systems, you cannot get the creation timestamp, you just get a copy of the last modification time. So sad, but unfortunately it's true. I'm not sure why this is so, but the code specifically does this, as shown below.
import java.io.IOException; import java.nio.file.*; import java.nio.file.attribute.*; public class TestFA { static void getAttributes(String pathStr) throws IOException { Path p = Paths.get(pathStr); BasicFileAttributes view = Files.getFileAttributeView(p, BasicFileAttributeView.class) .readAttributes(); System.out.println(view.creationTime()+" is the same as "+view.lastModifiedTime()); } public static void main(String[] args) throws IOException { for (String s : args) { getAttributes(s); } } }
David Nugent Jan 22 '13 at 9:56 2013-01-22 09:56
source share