public static void changeLocalFileUser ( String path , String user ) throws IOException { UserPrincipalLookupService lookupService = FileSystems . getDefault ( ) . getUserPrincipalLookupService ( ) ; PosixFileAttributeView view = Files . getFileAttributeView ( Paths . get ( path ) , PosixFileAttributeView . class , LinkOption . NOFOLLOW_LINKS ) ; UserPrincipal userPrincipal = lookupService . lookupPrincipalByName ( user ) ; view . setOwner ( userPrincipal ) ; }
Changes the local file s user .