jdk/test/java/nio/file/attribute/BasicFileAttributeView/Basic.java
changeset 15275 6e5b8f8361eb
parent 9035 1255eb81cc2f
child 17154 e8991539c4d7
equal deleted inserted replaced
15274:a77cdd5ea6e3 15275:6e5b8f8361eb
    47         check(attrs.isDirectory(), "is a directory");
    47         check(attrs.isDirectory(), "is a directory");
    48         check(!attrs.isRegularFile(), "is not a regular file");
    48         check(!attrs.isRegularFile(), "is not a regular file");
    49         check(!attrs.isSymbolicLink(), "is not a link");
    49         check(!attrs.isSymbolicLink(), "is not a link");
    50         check(!attrs.isOther(), "is not other");
    50         check(!attrs.isOther(), "is not other");
    51 
    51 
    52         // last-modified-time should match java.io.File
    52         // last-modified-time should match java.io.File in seconds
    53         File f = new File(dir.toString());
    53         File f = new File(dir.toString());
    54         check(f.lastModified() == attrs.lastModifiedTime().toMillis(),
    54         check(f.lastModified()/1000 == attrs.lastModifiedTime().to(TimeUnit.SECONDS),
    55               "last-modified time should be the same");
    55               "last-modified time should be the same");
    56     }
    56     }
    57 
    57 
    58     static void checkAttributesOfFile(Path dir, Path file)
    58     static void checkAttributesOfFile(Path dir, Path file)
    59         throws IOException
    59         throws IOException
    62         check(attrs.isRegularFile(), "is a regular file");
    62         check(attrs.isRegularFile(), "is a regular file");
    63         check(!attrs.isDirectory(), "is not a directory");
    63         check(!attrs.isDirectory(), "is not a directory");
    64         check(!attrs.isSymbolicLink(), "is not a link");
    64         check(!attrs.isSymbolicLink(), "is not a link");
    65         check(!attrs.isOther(), "is not other");
    65         check(!attrs.isOther(), "is not other");
    66 
    66 
    67         // size and last-modified-time should match java.io.File
    67         // size and last-modified-time should match java.io.File in seconds
    68         File f = new File(file.toString());
    68         File f = new File(file.toString());
    69         check(f.length() == attrs.size(), "size should be the same");
    69         check(f.length() == attrs.size(), "size should be the same");
    70         check(f.lastModified() == attrs.lastModifiedTime().toMillis(),
    70         check(f.lastModified()/1000 == attrs.lastModifiedTime().to(TimeUnit.SECONDS),
    71               "last-modified time should be the same");
    71               "last-modified time should be the same");
    72 
    72 
    73         // copy last-modified time and file create time from directory to file,
    73         // copy last-modified time and file create time from directory to file,
    74         // re-read attribtues, and check they match
    74         // re-read attribtues, and check they match
    75         BasicFileAttributeView view =
    75         BasicFileAttributeView view =