public List<T> read() throws IOException {
            String line = reader.readLine();
            if (line == null)
                return Collections.emptyList();

            int readVersion = toInt(line);
            if (readVersion != version) {
                throw new IOException("Unrecognised version:" + readVersion + ", expected version: " + version
                                              + " in checkpoint file at: " + location);
            }

            line = reader.readLine();
            if (line == null) {
                return Collections.emptyList();
            }
            int expectedSize = toInt(line);
            List<T> entries = new ArrayList<>(expectedSize);
            line = reader.readLine();
            while (line != null) {
                Optional<T> maybeEntry = formatter.fromString(line);
                if (!maybeEntry.isPresent()) {
                    throw buildMalformedLineException(line);
                }
                entries.add(maybeEntry.get());
                line = reader.readLine();
            }

            if (entries.size() != expectedSize) {
                throw new IOException("Expected [" + expectedSize + "] entries in checkpoint file ["
                                              + location + "], but found only [" + entries.size() + "]");
            }

            return entries;
        }
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