public static final void setOwner(String name, Path... files) throws IOException
    {
        if (supports("posix"))
        {
            for (Path file : files)
            {
                FileSystem fs = file.getFileSystem();
                UserPrincipalLookupService upls = fs.getUserPrincipalLookupService();
                UserPrincipal user = upls.lookupPrincipalByName(name);
                Files.setOwner(file, user);
            }
        }
        else
        {
            JavaLogging.getLogger(PosixHelp.class).warning("no owner support. setOwner(%s)", name);
        }
    }
public static final void setOwner ( String name , Path ... files ) throws IOException { if ( supports ( "posix" ) ) { for ( Path file : files ) { FileSystem fs = file . getFileSystem ( ) ; UserPrincipalLookupService upls = fs . getUserPrincipalLookupService ( ) ; UserPrincipal user = upls . lookupPrincipalByName ( name ) ; Files . setOwner ( file , user ) ; } } else { JavaLogging . getLogger ( PosixHelp . class ) . warning ( "no owner support. setOwner(%s)" , name ) ; } }
Change user of given files. Works only in linux.
@param name
@param files
@throws IOException
@see java.nio.file.Files#setOwner(java.nio.file.Path, java.nio.file.attribute.UserPrincipal)