I have to add one Disclaimer Line in a CSV file before the headers using Spring Batch implementation. For example, below is my expected CSV File:
Disclaimer-XYZ... Col1 Col2 Col3 abc efg pqr
Currently, I am using FlatFileItemWriter and FlatFileHeaderCallBack to create the CSV File along with writing headers and their corresponding values in it.
But I am not able to add a disclaimer and then follow by the Headers as shown above.
Here is a glimpse of my code:
stepWriter.setHeaderCallback(new FlatFileHeaderCallback()
public void writeHeader(Writer writer) throws IOException{`
writer.write(disclaimer);
writer.write(“Col1”, “Col2”,”Col3”);
}
});
But with the above code the actual CSV looks like this:
Disclaimer-XYZ Col1 Col2 Col3