I really don't see the problem. It adds all the names from the file in args[0], even with "-" or anything actually because I just don't modify them, I just cut the string at the begining of the numbers...
Can someone help me if there are still people here after the new paid membership?
package com.codegym.task.task19.task1921;
import java.io.BufferedReader;
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) {
try(BufferedReader reader = new BufferedReader(new FileReader(args[0]))) {
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd MM yyyy");
while (reader.ready()){
String lineFIle = reader.readLine();
String number = lineFIle.substring(lineFIle.length()-10);
String formatedNumber ="";
if (number.startsWith(" ")){
formatedNumber = number.replaceFirst(" ", "0");
}
else {
formatedNumber = number;
}
String name = lineFIle.replaceAll("[0-9]", "").trim();
Date date = DATE_FORMAT.parse ( formatedNumber );
PEOPLE.add(new Person(name, date));
}
}catch (Exception e) {
e.printStackTrace();
}
}
}