public class Solution { public static final List<Person> PEOPLE = new ArrayList<Person>(); public static void main(String[] args) throws IOException, ParseException { BufferedReader reader = new BufferedReader(new FileReader(args[0])); while (reader.ready()){ String str = reader.readLine(); String[] arrStr = str.split(" "); String name = ""; for (int i = arrStr.length; i > 3; i--){ name += (arrStr[arrStr.length - i] + " "); } String date = (arrStr[arrStr.length - 3]) + " " + (arrStr[arrStr.length - 2]) + " " + (arrStr[arrStr.length - 1]); SimpleDateFormat dateFormat = new SimpleDateFormat("dd MM yyyy"); Date date1 = dateFormat.parse(date); Person person = new Person(name, date1); PEOPLE.add(person); } reader.close(); for (Person p : PEOPLE){ System.out.println(p.getName() + " - " + p.getBirthDate()); } } }