还可以使用Files.setLastModifiedTime()方法来完成文件的上次修改时间:
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; /** from NowJava.com**/ 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); // update the file's last modified time with the setLastModifiedTime method/*来自 N o w J a v