I have the below requirement but am not able to decide on the approach to take:
I need to write data to a fixed format out put file where each record spans over mult
there is a multiline records writer example in the official spring-batch-samples, search for multiline.xml and MultiLineTradeItemWriter
its basically the usual delegate principle, you just need a proper domain object with supposable a list of those 1..n intermediate lines
public class MultiLineTradeItemWriter implements ItemWriter, ItemStream {
private FlatFileItemWriter delegate;
public void write(List extends Trade> items) throws Exception {
List lines = new ArrayList();
for (Trade t : items) {
lines.add("BEGIN");
lines.add("INFO," + t.getIsin() + "," + t.getCustomer());
lines.add("AMNT," + t.getQuantity() + "," + t.getPrice());
lines.add("END");
}
this.delegate.write(lines);
}
}