private void generateDataForCharset(final String feedName,
                                        final Path dir,
                                        final Charset charset,
                                        final ByteOrderMark byteOrderMark,
                                        final String sourceContent,
                                        final int iteration) {
        runAsync(() -> {
            LOGGER.info("Creating feed {} in {} for charset {} and BOM {}",
                    feedName, dir, charset, byteOrderMark);

            final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

            // Get the bytes of the desired charset
            byte[] sourceBytes = sourceContent.getBytes(charset);

            final Path file = makeInputFilePath(
                    dir,
                    1,
                    LocalDateTime.of(2020, 1, 1, 0, 0, 0)
                            .plusMonths(iteration),
                    feedName);

            LOGGER.info("Generating file {}, with charset {}, BOM {}",
                    file, charset, byteOrderMark);

            try (OutputStream outputStream = new FileOutputStream(file.toFile())) {

                // Write the BOM to the stream if we have one. We control the
                // presence of the BOM, not the java.
                if (byteOrderMark != null) {
                    byteArrayOutputStream.writeBytes(byteOrderMark.getBytes());
                }

                final BOMInputStream bomFreeInputStream = new BOMInputStream(
                        new ByteArrayInputStream(sourceBytes),
                        false);

                // now write the encoded bytes without the BOM
                bomFreeInputStream.transferTo(byteArrayOutputStream);

                byteArrayOutputStream.writeTo(outputStream);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
    }
To aid testing the generation without running {@link SetupSampleData}
stroom-app/src/test/java/stroom/test/SampleDataGenerator.java