Java Reference
In-Depth Information
<beans:property name="resource" ref="outputFile"/>
<beans:property name="lineAggregator" ref="formattedLineAggregator"/>
<beans:bean id="formattedLineAggregator"
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.
<beans:property name="names"
<beans:property name="format" value="%s %s lives at %s %s in %s, %s."/>
<step id="formatStep">
<chunk reader="customerFileReader" writer="flatFileOutputWriter"
<job id="formatJob">
<step id="step1" parent="formatStep"/>
After you build the project using Maven's mvn clean install command, you can execute the
example using CommandLineJobRunner with the command shown in Listing 9-8.
Listing 9-8. How to Execute formatJob from the Command Line
java -jar itemWriters-0.0.1-SNAPSHOT.jar jobs/formatJob.xml formatJob
customerFile=/input/customer.csv outputFile=/output/formattedCustomers.txt
When you run the job with the input specified in Listing 9-2, the result is a new file,
formattedCustomers.txt , with the contents listed in Listing 9-9.
Listing 9-9. formattedCustomers.txt
Richard Darrow lives at 5570 Isabella Ave St. Louis in IL, 58540.
Warren Darrow lives at 4686 Mt. Lee Drive St. Louis in NY, 94935.
Barack Donnelly lives at 7844 S. Greenwood Ave Houston in CA, 38635.
Ann Benes lives at 2447 S. Greenwood Ave Las Vegas in NY, 55366.
Erica Gates lives at 3141 Farnam Street Omaha in CA, 57640.
Warren Williams lives at 6670 S. Greenwood Ave Hollywood in FL, 37288.
Harry Darrow lives at 3273 Isabella Ave Houston in FL, 97261.
Steve Darrow lives at 8407 Infinite Loop Drive Las Vegas in WA, 90520.
Search WWH ::

Custom Search