0

i use chunk for write files. i have two tables files and datas

config.java

public ListItemReader<> reader(String fileName) {
    listItemReader = selectDataOfFileFromDB(fileName);
        ....
    return listItemReader;
}

public FlatFileItemWriter<> writer(fileName) {
    FlatFileItemWriter<> delegate = new FlatFileItemWriterBuilder<>
        .name(fileName+XXX)
        .resource(new FileSystemResource("/xxx/xxx/xxx/"+ fileName)).build();

    return delegate;
}

public Step xxxxStep(fileName) {
    return stepBuilderFactory.get("xxxxstep" + XXXX)
           .reader(reader(fileName))
           .writer(writer(fileName)).build();
}

@Bean
public Job xxxJob() {
    List<fileName> list = selectFileNameFromDB();

    JobBuilder xx = jobBuilderFactory.get("XXXXjob");
    SimpleJobBuilder a = null;

    a = xx.start(xxxxStep(list.get(0)));
    a.next(xxxxStep(list.get(1)))
    a.next(xxxxStep(list.get(2))
    a.next(xxxxStep(list.get(3))
    .....
    a.next(xxxxStep(list.get(n))
}

I can write data to each of file but it not smart. any other solution is?

I try the classifiercompositeitemwriter but not suitable!

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
David
  • 1
  • I have no idea what you want to achieve. Please clarify. – M. Deinum Nov 14 '22 at 07:14
  • Can you give some more information related to your requirement in terms of sample example. – Kunal Varpe Nov 14 '22 at 07:28
  • i find the same problem this is the link https://stackoverflow.com/questions/15974458/spring-batch-writing-data-to-multiple-files-with-dynamic-file-name – David Nov 14 '22 at 08:01
  • my solution has a problem is that all data in the memory at once.. i try to customer the multiresourceitemwriter. maybe can do it – David Nov 14 '22 at 08:03
  • If it is the same problem then the solution should work. If it isn't then don't point to it and properly describe your issue, you only told what (according to you) doesn't work. You haven't described what you want to achieve. – M. Deinum Nov 14 '22 at 10:33

0 Answers0