private void writeToFile(JsonNode jsonSchema, File file) throws MojoExecutionException {
        ObjectMapper mapper = getGenerator().getConfig().getObjectMapper();
        try (FileOutputStream outputStream = new FileOutputStream(file);
                PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8))) {
            writer.print(mapper.writeValueAsString(jsonSchema));
        } catch (IOException e) {
            throw new MojoExecutionException("Error: Can not write to file " + file, e);
        }
    }
Write generated schema to a file.

@param jsonSchema Generated schema to be written
@param file The file to write to
@throws MojoExecutionException In case of problems when writing the targeted file
jsonschema-maven-plugin/src/main/java/com/github/victools/jsonschema/plugin/maven/SchemaGeneratorMojo.java