code: public static void writeMemento(final File resourceDir, final Resource resource,
              final Instant time) {
          try (final BufferedWriter writer = newBufferedWriter(
                          getNquadsFile(resourceDir, time).toPath(), UTF_8, CREATE, WRITE,
                          TRUNCATE_EXISTING)) {
  
              try (final Stream<String> quads = generateServerManaged(resource).map(FileUtils::serializeQuad)) {
                  final Iterator<String> lineIter = quads.iterator();
                  while (lineIter.hasNext()) {
                      writer.write(lineIter.next() + lineSeparator());
                  }
              }
  
              try (final Stream<String> quads = resource.stream().filter(FileUtils::notServerManaged)
                      .map(FileUtils::serializeQuad)) {
                  final Iterator<String> lineiter = quads.iterator();
                  while (lineiter.hasNext()) {
                      writer.write(lineiter.next() + lineSeparator());
                  }
              }
          } catch (final IOException ex) {
              throw new UncheckedIOException(
                              "Error writing resource version for " + resource.getIdentifier().getIRIString(), ex);
          }
      }
docs: Write a Memento to a particular resource directory.
  @param resourceDir the resource directory
  @param resource the resource
  @param time the time for the memento