public static void writeDocument(@NotNull Document document, @NotNull OutputStream stream, String lineSeparator) throws IOException {
    try (OutputStreamWriter writer = new OutputStreamWriter(stream, StandardCharsets.UTF_8)) {
      writeDocument(document, writer, lineSeparator);
    }
  }
public static void writeDocument(@NotNull Document document, @NotNull OutputStream stream, String lineSeparator)