Back Forum Reply New

Look ahead to next flat file record

Does anyone have an example of reading a multi-line flat file where you cannot tell you have read all the related records until you hit the next group of records. For example:

ORDER1 XXXDATAXXX
ORDER1 YYYDATAYYY
ORDER1 YYYDATAYYY
ORDER1 YYYDATAYYY
ORDER1 ZZZDATAZZZ
ORDER1 ZZZDATAZZZ
ORDER2
ORDER2
ORDER2
ORDER3
ORDER4
ORDER4

Ideally I would like to have an item reader that reads all the records for ORDER1 but I do not know that ORDER1 is complete unless I know that the next record is ORDER2. One XXXDATAXXX can have many YYYDATAYYY so my domain object is just a root node with n number of children. I would like something where I read until I get to ORDER2, push that line of data back into the stream and then just return all the data for ORDER1. The next time I read from the stream it will begin with the first record for ORDER2 (The record I put back on the stream).

Sounds like a job for PeekableItemReader (from the framework)?
¥
Back Forum Reply New