Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java错误或windows错误与文件创建时间_Java_File_File Io_Filesystems_Nio - Fatal编程技术网

Java错误或windows错误与文件创建时间

Java错误或windows错误与文件创建时间,java,file,file-io,filesystems,nio,Java,File,File Io,Filesystems,Nio,删除并重新创建文件时,创建时间:始终与第一次创建文件时相同 Path path = Paths.get(file); BasicFileAttributes attr = Files.readAttributes(path , BasicFileAttributes.class); System.out.println("Creation time: " + attr.creationTime()) 添加完整的源代码: public class FileCreationTimeTest {

删除并重新创建文件时,创建时间:始终与第一次创建文件时相同

Path path = Paths.get(file);
BasicFileAttributes attr = Files.readAttributes(path , BasicFileAttributes.class);
System.out.println("Creation time: " + attr.creationTime())
添加完整的源代码:

public class FileCreationTimeTest {

    @Test
    public void testFileTimeCreation() throws Exception {
        for(int i = 0; i < 10; i++) {
            FileTime fileTime = getFileCreationTime();
            System.out.println(fileTime);
            Thread.sleep(1000);
            FileTime fileTime2 = getFileCreationTime();
            System.out.println(fileTime2);
            Assert.assertEquals(fileTime.compareTo(fileTime2), 0);
        }
    }

    private FileTime getFileCreationTime() throws Exception {
        File file = new File("test.txt");
        file.createNewFile();
        Path path = Paths.get(file.getAbsolutePath());
        BasicFileAttributes attr = Files.readAttributes(path , BasicFileAttributes.class);
        FileTime fileTime = attr.creationTime();
        file.delete();
        return fileTime;
    }
 }
环境:Windows 7、JRE 1.8.0_25


这是错误吗?

磁盘上的文件系统是什么?请提供文件删除和重新创建的完整代码