1

We are working on a Spring Batch Job, where we need to write to multiple files based on the size. For Example, we need to write to the output file output1.txt, once we reach 5 mb of the file size then it has to write into output2.txt. Please suggest

Is there any OOTB feature in Spring batch where we can achieve it or do we need to write custom code to achieve this

4

1 回答 1

1

Spring batch Item writers and especially FlatFileItemWriter's do not support a MaxFileSize property like you need and in fact it is not the job of writer to check the size.

I would suggest 1-) Implement your writer for one file and output output.txt in the first step. 2-) Implement a second step as a tasklet which takes output.txt as input and splits this file for the requested file size.

This way you will separate your file splitting logic from your main step.

于 2013-03-09T22:22:58.200 回答