BootstrapMetadata readFromBinaryFile(String binaryPath) throws Exception {
        List<ApiMessageAndVersion> records = new ArrayList<>();
        try (BatchFileReader reader = new BatchFileReader.Builder().
                setPath(binaryPath).build()) {
            while (reader.hasNext()) {
                BatchAndType batchAndType = reader.next();
                if (!batchAndType.isControl()) {
                    records.addAll(batchAndType.batch().records());
                }
            }
        }
        return BootstrapMetadata.fromRecords(Collections.unmodifiableList(records),
                "the binary bootstrap metadata file: " + binaryPath);
    }
Create a new BootstrapDirectory object.

@param directoryPath     The path to the directory with the bootstrap file.
@param ibp               The configured value of inter.broker.protocol, or the empty string
                         if it is not configured.
metadata/src/main/java/org/apache/kafka/metadata/bootstrap/BootstrapDirectory.java