Multi-Line Records Reader (when start prefix = end prefix)

后端 未结 1 403
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-18 10:28

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

相关标签:
1条回答
  • 2020-12-18 11:16

    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.

    0 讨论(0)
提交回复
热议问题