Creating a read/process/write step

A read/process/write step is a common type of step where some data is read somewhere, processed in some way, and finally, saved somewhere else. In this recipe, we'll read a CSV file of users, increment their age, and save the modified users in a database as shown in the following image:

Creating a read/process/write step

Getting ready

This is our CSV file of users, input_data.txt:

Merlin, 333
Arthur, 37
Lancelot, 35
Tristan, 20
Iseult, 22
Mark, 56

For each line of the CSV file, we'll create a User object. So, make sure that the User class exists:

public class User {
  private String firstName;
  private int age;
…
}

Each User object will be saved in the database. ...

Get Spring Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.