【问题标题】:How can i get the Created Date and Time of a file in java? [duplicate]如何在java中获取文件的创建日期和时间? [复制]
【发布时间】:2011-12-21 22:56:26
【问题描述】:

可能重复:
How to discover a File's creation time with Java?

我想在 java 中获取文件的创建日期和时间。 我该怎么做?

提前谢谢!!!!

【问题讨论】:

标签: java file


【解决方案1】:

您有 cmd /c dir fileName 命令来执行此操作:

尝试使用

Runtime runtime = Runtime.getRuntime();

Process output = runtime.exec("cmd /c dir "+fname);

处理运行时的输出,得到想要的戳记。

【讨论】:

  • 我已经通过了这个逻辑,但它不能正常工作。这个逻辑为每个文件提供相同的日期和时间。
【解决方案2】:

【讨论】:

  • 我试过了,但它没有给出正确的值。
  • +1 现在可以使用了。它需要一些改变。
猜你喜欢
  • 2011-11-29
  • 2017-12-16
  • 2010-09-19
  • 2011-10-16
  • 2013-01-28
  • 2014-06-08
  • 2019-08-23
  • 1970-01-01
  • 2020-11-12
相关资源
最近更新 更多