code: public static void fsync(final Path path) throws IOException {
          if (! Files.isDirectory(path) && ! Files.isRegularFile(path)) {
              throw new IllegalArgumentException("fsync is only supported for regular files and directories: " + path);
          }
  
          try (final FileChannel channel = FileChannel.open(path, StandardOpenOption.READ)) {
              channel.force(true);
          }
      }
docs: Fsync a single path. Please only call this on things that are Directories or NormalFiles.
  
  @param path path to fsync
  @throws IOException in the event that we could not fsync the provided path.