以下引文摘自javadoc 。
FileTime creationTime() Returns the creation time. The creation time is the time that the file was created. 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).
Returns: a FileTime representing the time the file was created
我得到的是上次修改时间而不是创建时间。 还有其他人使用 ubuntu 11.10 确认 Ubuntu 11.10 文件系统实际上没有实现该功能吗? 提前致谢。
最佳答案
这取决于文件系统,ext3 不存储创建时间。 Ext4 确实有一个字段“crtime”来保存此信息。 自 9.10 以来,ext4 一直是 Ubuntu 中的默认文件系统,因此您可能有一个 ext4 文件系统。
编辑: 好吧,显然在 Unix 文件系统上你无法检索创建时间戳,你只能获得最后修改时间的副本。
在 UnixFileAttributes.java 中:
@Override
public FileTime creationTime() {
return lastModifiedTime();
}
关于java - Ubuntu 11.10文件系统没有实现creationTime?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16402554/