Row count in the file header and using RandomAccessFile in the StepExecutionListener
I have to put the total row count in the header of a file. I am trying to update the file in the 'afterStep' callback of StepExecutionListener. I am doing this by creating an object of RandomAccessFile (with "rw" mode) an updating the first line of the file (the main file on which the writer worked upon) with RandomAccessFile.writeBytes method. But this does not seem to be working at all. Nothing happens. No error or exception but no updated either. My main file gets generated properly with all the expected data inside it but there is no update in the header.
To dig in further I have tried to create a totally new file also in the callback method and even that is not being created. Bizzarely a empty 0-byte file with only 'file' as a name is created in the directory. Again, the main file is generated properly.
I am using a CompositeItemWriter which delegates the file writing to a FlatFileItemWriter extended class. I am also using Header and Footer callbacks.
Please advise. Thanks a lot. What am I missing?
Edit: Please delete this thread. It was a file resource path issue which is resolved. Sorry for any inconvenience.