FlatFileItemWriter<FieldSet> writer = new FlatFileItemWriter<FieldSet>();
FileSystemResource resource = new FileSystemResource("target/output/output.txt");
FileUtils.deleteQuietly(resource.getFile());
writer.setResource(resource);
writer.setHeaderCallback(new FlatFileHeaderCallback() {
public void writeHeader(Writer writer) throws IOException {
for (String header : headers) {
writer.write(header);
}
}