Please. Could someone please explain to me how to add names to people? I don't understand.
package fr.codegym.task.task19.task1921;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/*
John Johnson
*/
public class Solution {
public static final List<Person> PEOPLE = new ArrayList<>();
public static void main(String[] args) throws IOException {
String fileName = args[0];
ArrayList<String> fileContent = new ArrayList<>();
try (BufferedReader fileReader = new BufferedReader(new FileReader(fileName))) {
String fileLine;
while ((fileLine = fileReader.readLine()) != null)
fileContent.add(fileLine);
} catch (IOException ignored) {
}
String s ;
String name;
Date birthdate = new Date();
for (String u : fileContent){
//we replace all the characters that are numbers and we process the name part
name = u.replaceAll("\\d","").trim();
//all characters that are not numbers are replaced and the numbers are kept.
String[] n = u.replaceAll("\\D","").trim().split(" ");
// the date part is processed
birthdate.setMonth(Integer.parseInt(n[0]));
birthdate.setDate(Integer.parseInt(n[1]));
birthdate.setDate(Integer.parseInt(n[2]));
// we add to the list of persons
Person person = new Person(name,birthdate);
PEOPLE.add(person);
}
}
}