更新任何或所有文件的最后修改时间,最后访问时间,并创建时间属性
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; /* *来 自 n o w j a v a . c o m - 时 代 Java */ import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.FileTime; public class Main { public static void main(String[] args) { Path path = Paths .get("D:\\folder0\\Java\\JDK7\\folder5\\code\\folder1\\folder2\\folder6","test.txt"); // update any or all of the file's last modified time, last access time, and create time attributes long time = System.currentTimeMillis(); FileTime fileTime = FileTime.fromMillis(time); try { Files.getFileAttributeView(path, BasicFileAttributeView.