public static final FileAttribute < UserPrincipal > getOwnerAsAttribute ( String owner ) throws IOException { if ( supports ( "posix" ) ) { UserPrincipalLookupService upls = FileSystems . getDefault ( ) . getUserPrincipalLookupService ( ) ; UserPrincipal user = upls . lookupPrincipalByName ( owner ) ; return new FileAttributeImpl <> ( "posix:owner" , user ) ; } else { return null ; } }
Return file owner as attribute if posix supported . Otherwise returns null .