• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Creation date of file

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I tried this:
Path path = Paths.get("file_path"); // e.g. file_path(String): c:\\exdatis\\etc...
BasicFileAttributes attr;
try {
attr = Files.readAttributes(path, BasicFileAttributes.class);

System.out.println("Creation date: " + attr.creationTime());

} catch (Exception e) {
System.out.println( e.getMessage());
}

I think it's ok on win OS, but not with Linux, also there is need(nio):
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;
Is there something different, to find date creation of file? Some simple way?
Thank you very much and best regards!


 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not all filesystems support this feature, so it is possible that this doesn't return the true creation date of the file. Apparently the Linux version and filesystem you are using does not support this. If the filesystem does not store this information, then there's no way to know it, because the information simply isn't stored on the disk.

Note that the API documentation already mentions this:

If the file system implementation does not support a time stamp to indicate the time of last modification then this method returns an implementation specific default value, typically a FileTime representing the epoch (1970-01-01T00:00:00Z).


 
Z Morar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Not all filesystems support this feature...


That's it.
Thank you very much!

p.s. XUbuntu 14.04 32 bit - returns last modified date...
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic