java复制文件后保持文件的创建时间不变

  • 复制后保持文件的创建时间不变
		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);

猜你喜欢

转载自blog.csdn.net/weixin_43684214/article/details/130601126