I\'m implementing Multi-Line Records Reader solution based on https://docs.spring.io/spring-batch/reference/html/patterns.html#multiLineRecords
I have the following
As the reference docs mention, you should create a custom implementation of ItemReader
to wrap the FlatFileItemReader
.
More specifically, you may want to extend SingleItemPeekableItemReader
and use FlatFileItemReader
as your delegate.
You'd peek()
ahead to the next item. If it's part of your current item
, great, go ahead and augment your item. If it's the next "header" line, then you've finished the item you're working and can return the current item
.
Then, the next read()
will start on the line you just peeked at without losing your place in the file or messing up restartability.