Re: File.copy while preserving the modification date

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/Problem-with-Maximum-intensity-projection-tp5020309p5020333.html

Hi Norbert,

well, I couldn't find a File.copy method in the documentation of Java 7
or Java 8.
Do you refer to the ImageJ File.copy macro function?
Its code is here:
https://github.com/imagej/imagej1/blob/master/ij/macro/Functions.java#lL4204

Already the early Java versions have
   long File.lastModified()
and
   File.setLastModified(long time)

I think you can use these to transfer the modification date (I have not
tried).

(If this might be useful for others, maybe we could have the file
copying function in somewhere in ij.utils or IJ.java, maybe preserving
the date?)

Michael
________________________________________________________________


On 2018-03-25 17:16, Norbert Vischer wrote:

> 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

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