解决方法
我不确定你是如何使用Java 6及以下版本的.使用Java 7的新文件系统API,它看起来像这样:
Path path = ... // the path to the file BasicFileAttributes attributes = Files.readAttributes(path,BasicFileAttributes.class); FileTime creationTime = attributes.creationTime();
正如CoolBeans所说,并非所有文件系统都存储创建时间. BasicFileAttributes Javadoc声明:
If the file system implementation does not support a time stamp to indicate the time when the file was created then this method returns an implementation specific default value,typically the last-modified-time or a FileTime representing the epoch (1970-01-01T00:00:00Z).