Jul 9th, 2008, 02:35 PM
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?
Jul 10th, 2008, 02:05 PM
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.
Jul 11th, 2008, 10:45 AM
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?