Announcement Announcement Module
No announcement yet.
A question on Delimiter/Record Seperation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • A question on Delimiter/Record Seperation


    I have just strated with spring batch and I am trying to read a file which has records of following type:

    ## START FILE <this is file header>
    ## 123 john f kennedy <start of a 1st record>
    02 white house
    04 whashington 19100023
    ## 456 george bush <start of a 2nd record>
    02 white house
    04 whashington 19100023
    ## END OF FILE <this is the file footer>

    I dont have to do anything with the record itself except writing it as it is to a file. So basically I just need the values between ## and ## to be written to a file.

    I went through the code and figured out that I have to use a RecordSeperatorPolicy for specifying the seperation of record. Looks like the current code just checks for the "isEndOfRecord" by checking if the line ends with the specified string.

    However, in my case, there is nothing to specify the end of record. The file structure is such, that a new record starts with "##".

    So even if I write my own RecordSeperationPolicy, and I check if the line starts with "##", I have no way of sending the text after "##" as start of next record.

    I might be wrong with whatever I have understood, so please correct me.
    Any ideas?

  • #2
    One way to go is to use composite item reader as the multilineOrderJob sample shows. If you think the RecordSeparatorPolicy could be made more helpful feel free to propose improvements.


    • #3
      Thanks Robert.
      Having a compsoite item reader solved it.

      RecordSeparatorPolicy can have a isStartofRecord method to handle such situations.