public static <K, V> Printed<K, V> toFile(final String filePath) {
        Objects.requireNonNull(filePath, "filePath can't be null");
        if (Utils.isBlank(filePath)) {
            throw new TopologyException("filePath can't be an empty string");
        }
        try {
            return new Printed<>(Files.newOutputStream(Paths.get(filePath)));
        } catch (final IOException e) {
            throw new TopologyException("Unable to write stream to file at [" + filePath + "] " + e.getMessage());
        }
    }
Print the records of a {@link KStream} to a file.

@param filePath path of the file
@param <K>      key type
@param <V>      value type
@return a new Printed instance
streams/src/main/java/org/apache/kafka/streams/kstream/Printed.java