Class FlatFileGenerator

java.lang.Object
io.bloviate.file.FlatFileGenerator
All Implemented Interfaces:
FileGenerator

public class FlatFileGenerator extends Object implements FileGenerator
Generator for creating flat files (CSV, TSV, pipe-delimited) with synthetic data.

The FlatFileGenerator creates delimited text files containing randomly generated data based on configurable column definitions. It supports multiple output formats including CSV, tab-delimited (TSV), and pipe-delimited files.

Key features:

  • Support for CSV, TSV, and pipe-delimited output formats
  • Configurable number of rows and columns
  • Automatic header generation with column names
  • Integration with ColumnDefinition and DataGenerator
  • YAML configuration export capability

Example usage:

List<ColumnDefinition> columns = Arrays.asList(
    new ColumnDefinition("id", new IntegerGenerator(random)),
    new ColumnDefinition("name", new StringGenerator(random))
);

new FlatFileGenerator.Builder("output-file")
    .addAll(columns)
    .rows(1000)
    .output(new CsvFile())
    .build()
    .generate();
Author:
Tim Veil
See Also:
  • Method Details

    • generate

      public void generate()
      Description copied from interface: FileGenerator
      Generates the output data file, writing one header row followed by the configured number of data rows.
      Specified by:
      generate in interface FileGenerator
    • yaml

      public void yaml()
      Description copied from interface: FileGenerator
      Exports this generator's configuration to a YAML file (named after the generator's base file name with a .yaml extension).
      Specified by:
      yaml in interface FileGenerator
    • getFileName

      public String getFileName()
      Returns the base output file name (the format-specific extension is appended at generation time).
      Returns:
      the base file name
    • getDefinition

      public FileDefinition getDefinition()
      Returns the file format definition controlling the delimiter and extension.
      Returns:
      the file format definition
    • getColumnDefinitions

      public List<ColumnDefinition> getColumnDefinitions()
      Returns the column definitions, in output order.
      Returns:
      the column definitions
    • getRows

      public long getRows()
      Returns the number of data rows to generate, excluding the header row.
      Returns:
      the data row count