Announcement Announcement Module
No announcement yet.
Delete Flat File after reading Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Delete Flat File after reading

    Hi guys,

    I am new to Spring Batch. I have a simple setup that uses FlatFileItemReader to read in a file and then uses a writer to write it to a database. I would like to delete the file after it is read (or after the writer, doesn't matter). What is the best/simplest way to do this?

    Here is part of the code snippet for the reader:

    <beans:bean id="MultiResourceItemReader.MemberRegistration" class="org.springframework.batch.item.file.MultiRe sourceItemReader">
    <beansroperty name="resources" value="file:\DataExtractSampleFiles\*MEM_REG.txt "/>
    <beansroperty name="delegate" ref="ItemReader.MemberRegistration">

    <beans:bean id="ItemReader.MemberRegistration" class="org.springframework.batch.item.file.FlatFil eItemReader">
    <beansroperty name="lineMapper">
    <beans:bean class="org.springframework.batch.item.file.mapping .DefaultLineMapper">
    <beansroperty name="lineTokenizer">
    <beans:bean class="org.springframework.batch.item.file.transfo rm.DelimitedLineTokenizer">
    <beansroperty name="delimiter" value="|"/>
    <beansroperty name="names" value="memberId,loginName,email,registrationDate,l astAccessedDate,cobrandId,country,state,city,zipCo de,ipAddress,guid,extractDate,extractDateMilliseco nds"/>
    <beansroperty name="fieldSetMapper">
    <beans:bean class="" />

  • #2
    Not sure if you found the answer. But, this specific issues has been discussed in the past..

    You can implement step/job listener and implement file archival/deletion from there.