public Map<TopicPartition, Long> read() throws IOException {
        synchronized (lock) {
            try (final BufferedReader reader = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
                final int version = readInt(reader);
                switch (version) {
                    case 0:
                        int expectedSize = readInt(reader);
                        final Map<TopicPartition, Long> offsets = new HashMap<>();
                        String line = reader.readLine();
                        while (line != null) {
                            final String[] pieces = WHITESPACE_MINIMUM_ONCE.split(line);
                            if (pieces.length != 3) {
                                throw new IOException(
                                    String.format("Malformed line in offset checkpoint file: '%s'.", line));
                            }

                            final String topic = pieces[0];
                            final int partition = Integer.parseInt(pieces[1]);
                            final TopicPartition tp = new TopicPartition(topic, partition);
                            final long offset = Long.parseLong(pieces[2]);
                            if (isValid(offset)) {
                                offsets.put(tp, offset);
                            } else {
                                LOG.warn("Read offset={} from checkpoint file for {}", offset, tp);
                                --expectedSize;
                            }

                            line = reader.readLine();
                        }
                        if (offsets.size() != expectedSize) {
                            throw new IOException(
                                String.format("Expected %d entries but found only %d", expectedSize, offsets.size()));
                        }
                        return offsets;

                    default:
                        throw new IllegalArgumentException("Unknown offset checkpoint version: " + version);
                }
            } catch (final NoSuchFileException e) {
                return Collections.emptyMap();
            }
        }
    }
Reads the offsets from the local checkpoint file, skipping any negative offsets it finds.

@throws IOException if any file operation fails with an IO exception
@throws IllegalArgumentException if the offset checkpoint version is unknown
streams/src/main/java/org/apache/kafka/streams/state/internals/OffsetCheckpoint.java