code: public static void changeLocalFileGroup(String path, String group) throws IOException {
      UserPrincipalLookupService lookupService =
          FileSystems.getDefault().getUserPrincipalLookupService();
      PosixFileAttributeView view =
          Files.getFileAttributeView(Paths.get(path), PosixFileAttributeView.class,
              LinkOption.NOFOLLOW_LINKS);
      GroupPrincipal groupPrincipal = lookupService.lookupPrincipalByGroupName(group);
      view.setGroup(groupPrincipal);
    }
docs: Changes the local file's group.
  
  @param path that will change owner
  @param group the new group