Login  Register

File.copy while preserving the modification date

Posted by vischer on Mar 25, 2018; 3:16pm
URL: http://imagej.273.s1.nabble.com/Problem-with-Maximum-intensity-projection-tp5020309p5020332.html

Hello all,

when using:

        File.copy(path1, path2);
 
the modification date of the the copied file changes to "now".
This is not correct and misleading, as the file content was not changed.

When going to:
        https://stackoverflow.com/questions/21215883/preserve-file-creation-time-with-java
I find the method:
        Files.copy(source, target, StandardCopyOption.COPY_ATTRIBUTES);
which should be supported from Java 7,
However, I did not succeed to get it work

My questions:

a) wouldn't it make sense that the File.copy method preserves the modification date?
b) Is there somewhere a working Java snippet that I can get working?

Best, Norbert

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html