public void write(Collection<T> entries) throws IOException {
        synchronized (lock) {
            // write to temp file and then swap with the existing file
            try (FileOutputStream fileOutputStream = new FileOutputStream(tempPath.toFile());
                 BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8))) {
                CheckpointWriteBuffer<T> checkpointWriteBuffer = new CheckpointWriteBuffer<>(writer, version, formatter);
                checkpointWriteBuffer.write(entries);
                writer.flush();
                fileOutputStream.getFD().sync();
            }

            Utils.atomicMoveWithFallback(tempPath, absolutePath);
        }
    }
This class represents a utility to capture a checkpoint in a file. It writes down to the file in the below format.
<pre>
========= File beginning =========
version: int
entries-count: int
entry-as-string-on-each-line
========= File end ===============
</pre>
Each entry is represented as a string on each line in the checkpoint file. {@link EntryFormatter} is used
to convert the entry into a string and vice versa.

@param <T> entry type.
server-common/src/main/java/org/apache/kafka/server/common/CheckpointFile.java