code: 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);
    }
docs: Changes the local file's user.
  
  @param path that will change owner
  @param user the new user