public static void stringToFile(final String string, final Path file, final Charset charset) {
        try {
            if (Files.isRegularFile(file)) {
                FileUtil.deleteFile(file);
            }
            Files.createDirectories(file.getParent());
            Files.writeString(file, string, charset);
        } catch (final IOException ioEx) {
            // Wrap it
            throw new UncheckedIOException(ioEx);
        }
    }
Takes a string and writes it to a file.
stroom-util/src/main/java/stroom/util/io/StreamUtil.java