You can use MultiResourceItemReader
.
See following sample code
<bean id="multiResourceItemReader" class="org.springframework.batch.item.file.MultiResourceItemReader">
<property name="resources"
value="file:./src/main/resources/input/*.txt" /> <property
name="delegate"> <bean
class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names" value="firstname,lastname,birth" />
</bean>
</property>
<property name="fieldSetMapper">
<bean class="com.zenika.workshop.springbatch.ContactFieldSetMapper" />
</property>
</bean>
</property> </bean> </property> </bean>
Here the MultiResourceItemReader
is reading all .txt
file from /src/main/resources/input
folder.