Keep the creation time of the file unchanged after copying the file in java

  • Keep the creation time of the file after copying
		File oldFile = new File("E:\\test\\old.png");
        File newFile = new File("E:\\test\\new.png");
        FileCopyUtils.copy(oldFile,newFile);
        Object creationTime = Files.getAttribute(Paths.get(oldFile.getAbsolutePath()), "creationTime");
        Files.setAttribute(Paths.get(newFile.getAbsolutePath()), "creationTime", creationTime);

Guess you like

Origin blog.csdn.net/weixin_43684214/article/details/130601126