java - Ubuntu 11.10文件系统没有实现creationTime?

标签 java filesystems unix-timestamp

以下引文摘自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/

相关文章:

javascript - 如何使用 javascript 文件系统 api 重命名目录?

java - PHP 和 Java Unix 时间戳之间的差异

mysql - 使用 MySQL 将 Unix 时间戳转换为人类可读的日期

java - java中不同的数据类型

java - 如何更改 javafx 中组合框项目的文本对齐方式?

c++ - 在 Linux 中以 C/C++ 编程方式更改文件的创建时间戳

java - 将 Joda LocalDate 转换为 Unix 纪元时间

Java 循环和零除数

java - 构造函数超出 65535 字节限制

java - 存储在磁盘上的图像 - 按名称搜索