public static void writeDocument(@NotNull Document document, @NotNull Path file, String lineSeparator) throws IOException {
    Path parent = file.getParent();
    if (parent != null) {
      NioFiles.createDirectories(parent);
    }

    try (BufferedWriter writer = Files.newBufferedWriter(file)) {
      writeDocument(document, writer, lineSeparator);
    }
  }
public static void writeDocument(@NotNull Document document, @NotNull Path file, String lineSeparator)