package com.ankurm.brokers; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; /** Writes a transcript under docs/output/. Nothing in the article is typed by hand. */ public final class Capture { private Capture() { } public static void write(String fileName, String heading, String body) { Path dir = Path.of(System.getProperty("user.dir"), "docs", "output"); try { Files.createDirectories(dir); Files.writeString(dir.resolve(fileName), "== " + heading + " ==\n\n" + body + "\n"); } catch (IOException ex) { throw new IllegalStateException("could not write " + fileName, ex); } } }