public static Consumer<Stream<String>> getFileOutputConsumer(final Path filePath,
                                                                 final String recordSeparator) {
        Objects.requireNonNull(filePath);
        Objects.requireNonNull(recordSeparator);

        ensureDirectories(filePath);

        return recordStream -> {
            try {
                try (final BufferedWriter writer = new BufferedWriter(
                        new FileWriter(filePath.toFile(), true))) {

                    AtomicBoolean isFirstRecord = new AtomicBoolean(true);
                    recordStream.forEach(recordStr -> {
                        try {
                            if (!isFirstRecord.get() && !recordSeparator.isEmpty()) {
                                writer.append(recordSeparator);
                            }
                            writer.append(recordStr);
                        } catch (IOException e) {
                            throw new RuntimeException("Error writing line to file "
                                                       + filePath.toAbsolutePath().normalize().toString() + ": "
                                                       + e.getMessage());
                        }
                        isFirstRecord.set(false);
                    });
                }
            } catch (IOException e) {
                throw new RuntimeException("Error writing to file "
                                           + filePath.toAbsolutePath().normalize().toString() + ": "
                                           + e.getMessage());
            }
        };
    }
@param filePath        The path of the file to write, any parent directories will be created.
@param recordSeparator The string to separate records with
@return A pre-canned stream consumer that writes each string to the file
at filePath
stroom-test-common/src/main/java/stroom/test/common/data/DataGenerator.java