Announcement Announcement Module
No announcement yet.
Write first line after execution Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Write first line after execution


    I am currently implementing Spring Batch for a project, but I have a problem, I am moving db data with a driving query to a flat file, at the beginning I must leave a blank line before I start processing objects, at the end I must write a summary to the first line in the file, can anybody give me a hint on how to do this?


  • #2
    Personally, I would probably just create separate file for the summary line and cat it with the output file. However, if you know exactly how long the summary line would be, you could write a blank string at the beginning of the step, then replace it by writing out the correct number of bytes to overwrite your original write. However, if you don't know the length of the line, you pretty much have to cat.

    As a sidenote, a StepExecutionListener can be used to be notified of the step beginning and ending.


    • #3
      Thanks Lucas, actually I will know the length of the line before hand, it must be 64 characters in length, could you elaborate a bit on how exactly I can overwrite this line?

      thank you,