I'm attempting to use
jackson-dataformat-csv to dynamically produce
.csv templates of specific objects that I intend to use for importing data.
So far I have this working, except for one facet - I have had to bodge it so that it doesn't expect anything after the schema. I'm convinced there must be a way to avoid this, but I can't find anything documented, or a way of otherwise producing a string that isn't just a
toString() of the object. The code I have is:
final CsvSchema schema = mapper.schemaFor( templateClass ).withHeader(); return mapper.writer( schema.withHeader() ).writeValueAsString( "" );
templateClass is whichever class is passed in as an arg)
This gives an output with the headers, then a blank row, e.g.
| column | column | column | +--------+--------+--------+ | | | |
Which is fine - I can leave it a bit bodgy for now, but can't help but feel I'm missing the correct way to do this.