// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the UserService.
UserServiceInterface userService =
user.getService(DfpService.V201211.USER_SERVICE);
// Set the user's email addresses and names.
List<String[]> emailAndNames = new ArrayList<String[]>();
emailAndNames.add(new String[] {"INSERT_EMAIL_ADDRESS_HERE",
"INSERT_NAME_HERE"});
emailAndNames.add(new String[] {"INSERT_ANOTHER_EMAIL_ADDRESS_HERE",
"INSERT_ANOTHER_NAME_HERE"});
// Roles can be obtained by running GetAllRolesExample.java.
Long roleId = Long.parseLong("INSERT_ROLE_ID_HERE");
// Create an array to store local user objects.
User[] users = new User[emailAndNames.size()];
for (int i = 0; i < users.length; i++) {
// Create the new user structure.
User newUser = new User();
newUser.setEmail(emailAndNames.get(i)[0]);
newUser.setName(emailAndNames.get(i)[1]);
newUser.setRoleId(roleId);
newUser.setPreferredLocale("en_US");
users[i] = newUser;
}
// Create the users.
users = userService.createUsers(users);
if (users != null) {
for (User newUser : users) {
System.out.println("A user with ID \"" + newUser.getId()
+ "\", email \"" + newUser.getEmail()