I do it in my talk JSR-352, Spring Batch, and You (https://www.youtube.com/watch?v=yKs4yPs-5yU). There, I use the SystemCommandTasklet
in combination with OS X's split command. You can see the example configuration in the repository for that talk here: https://github.com/mminella/jsr352-springbatch-and-you.
The specific example would be as follows:
<bean id="fileSplittingTasklet" class="org.springframework.batch.core.step.tasklet.SystemCommandTasklet" scope="step">
<property name="command" value="split -a 5 -l 10000 #{jobParameters['inputFile']} #{jobParameters['stagingDirectory']}"/>
<property name="timeout" value="60000"/>
<property name="workingDirectory" value="/tmp/jsr_temp"/>
</bean>
This is the preferred approach for splitting a file. The file system/OS level tools are much faster than piping the file through the java process.