Java 8 PosixFileAttributes - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PosixFileAttributes class.

This code example shows how to use the following methods:group, owner, permissions
This code example shows how to use the following methods:fileKey, owner
 
    assertThat(view.name()).isEqualTo("posix");
    assertThat(view.getOwner()).isEqualTo(createUserPrincipal("user"));
 
    PosixFileAttributes attrs = view.readAttributes();
    assertThat(attrs.fileKey()).isEqualTo(0);
    assertThat(attrs.owner()).isEqualTo(createUserPrincipal("user"));
    assertThat(attrs.group()).isEqualTo(createGroupPrincipal("group"));
    assertThat(attrs.permissions()).isEqualTo(PosixFilePermissions.fromString("rw-r--r--"));
 
    view.setOwner(createUserPrincipal("root"));
    assertThat(view.getOwner()).isEqualTo(createUserPrincipal("root"));
    assertThat(file.getAttribute("owner", "owner")).isEqualTo(createUserPrincipal("root")); 
 
    view.setGroup(createGroupPrincipal("root"));
    assertThat(view.readAttributes().group()).isEqualTo(createGroupPrincipal("root"));
    assertThat(file.getAttribute("posix", "group")).isEqualTo(createGroupPrincipal("root")); 
 
    view.setPermissions(PosixFilePermissions.fromString("rwx------"));
    assertThat(view.readAttributes().permissions()).isEqualTo(
4
CodeRank
This code example shows how to use the following methods:size
 
        if ( create ) {
            attributes = provider.createFile( path, createFileAttributes );
        } 
 
        size = attributes.size();
 
        open = true;
 
        // maybe wanna lock file a la 'flock' 
    } 
 
    @Override 
    public void close() throws IOException {
        open = false;
    } 
 
    @Override 
    public boolean isOpen() { 
        return open;
3
CodeRank
See Code Examples for Java 8 PosixFileAttributes Methods: