Reputation: 791
I am a newbie in Spring Batch. I have already created working code using FlatFileItemReader where I am getting the preset file name from a property file. In a new requirement I would not know the file name. For instance, the below could be the files and their names, all placed in the same location.
...\files2read\<SOME-RANDOM-ID>.<YYMMDD>.<EXTN>
...\files2read\123.140613.ABB - @Pick this
...\files2read\234.140610.ABB
...\files2read\345.140607.ABB
...\files2read\123.140613.ABC - @Pick this
...\files2read\234.140610.ABC
...\files2read\345.140607.ABC
...\files2read\123.140613.ABD - @Pick this
...\files2read\234.140610.ABD
...\files2read\345.140607.ABD
There might be multiple files as the time goes, but I need to pick the latest file looking at the date on the file name, and per each file extension (i.e., @Pick this)
I have looked at the MultiResourceItemReader where the resources can be specified as pattern. This will allow me to read all the files matching a file extension but not as I require here. Is there an elegant solution to this, rather than writing each file type pattern as a separate step? Also I still not sure how to pick the latest file looking at the date here.
I am using this example as a reference. Please let me know your thoughts. Thanks in advance.
Upvotes: 1
Views: 1285
Reputation: 18413
You can implements your own ResourcePatternResolver
and return resources you want.
Upvotes: 0