假如你的jdk环

境可以在1.7或之上,推荐你用nio包下的一个对象

代码如下

Path p = Paths.get("C:/1.txt")
 
  try {
 
   BasicFileAttributes att = Files.readAttributes(p, BasicFileAttributes.class);//获取文件的属性
   att.creationTime().toMillis();
 
   att.lastAccessTime().toMillis();
 
   att.lastModifiedTime().toMillis();
 
  catch (IOException e1) {
 
   e1.printStackTrace();
 
  }

 

相关文章:

  • 2022-02-25
  • 2021-11-26
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-02
  • 2021-06-29
  • 2022-12-23
  • 2021-11-30
  • 2021-09-08
  • 2021-06-18
相关资源
相似解决方案