title: How to read and parse data from file?
body: <p>My Task is to read some data from file, split it and then parse it to correct instance of class. So far so good, but I have a problem with the class <code>Education</code>, because every person has different education degree, so I don't know how to check that. The same problem comes with <code>Insurance</code> class, because for every person we have information for different period of time. So that is my problem basicaly.</p>
  
  <p>I don't know how many instances of <code>Education</code> I have to create.</p>
  
  <p>Here are two examples of the data that I have to read and parse:</p>
  
  <pre><code>--1--
  "Plamen;Stoichev;Izmirliev;M;16.7.1980;206;Bulgaria;Sofiya;Studentski;1016;Opalchenska;21;;;P; William Gladstoine;15.9.1986;15.6.1993;S;William Gladstoine ;15.9.1993;30.6.1998;3.343;B; William Gladstoine;1.10.1999;1.6.2003;3.045" +
  "2016;11;1015.20;2016;10;605.93;2016;9;701.61;2016;7;981.86;2016;4;1042.57;2016;3;919.87;2016;2;720.00;2015;12;969.75;2015;6;641.16;2015;3;811.76;2015;2;757.07;2014;12;1321.31;2014;11;863.39;2014;9;1539.51;2014;7;1159.62;2014;5;1295.59;2014;3;910.59;2014;1;1033.80";
  
  --2--
  Violeta;Konstantinova;Orlova;F;23.8. 1982;148;Bulgaria;Sofia;Izgrev;1008;King Boris III;123;5;26;P;William Gladstoine ;15.9.1988;15.6.1995;S;William Gladstoine ;15.9.1995;30.6.2000;4.069
  2016;11;1587.70;2016;8;1524.04;2016;6;1273.10;2016;4;1129.08; 2016;2;1469.79;2015;12;927.91;2015;10;1116.83;2015;6;1143.05;2015;4;1348.82;
  </code></pre>
  
  <p>The <code>SocialInsuranceRecord</code> class has three parameters <code>year</code>, <code>month</code>, <code>tax amount</code>.
  The <code>Education</code> class has <code>level of degree</code>, <code>name of school</code>, <code>enrollment date</code>, <code>graduation date</code>, <code>average grade</code>;</p>
  
  <pre><code>import java.nio.file.Files;
  import java.nio.file.Paths;
  import java.time.LocalDate;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Scanner;
  
  import DataObjects.address.Address;
  import DataObjects.education.Education;
  import DataObjects.insurance.SocialInsuranceRecord;
  import DataObjects.personaldetails.Citizen;
  import DataObjects.personaldetails.Gender;
  
  public class GetDataFromFile {
      private List&lt;Citizen&gt; citizents = new ArrayList&lt;&gt;();
      private static final String FILE_PATH = "D:\\data.dat";
  
      public List&lt;Citizen&gt; getCitizens() {
          List&lt;Citizen&gt; list = new ArrayList&lt;&gt;();
          try {
              Scanner scanner = new Scanner(new String(Files.readAllBytes(Paths.get(FILE_PATH))));
              while(scanner.hasNext()) {
                  Citizen citizen = parseCitizent(scanner.nextLine());
                  list.add(citizen);
              }
  
          }catch(Exception ex) {
              ex.printStackTrace();
          }
          return list;
      }
  
      public Citizen parseCitizent(String nextLine) {
          String[] split = nextLine.split("\\s*;");
  
          Citizen citizen = new Citizen(split[0], split[1], split[2], Gender.valueOf(split[3]), LocalDate.parse(split[4]), Integer.parseInt(split[5]));       
          Address address = new Address(split[6], split[7], split[8], split[9], split[10], split[11], Integer.parseInt(split[11]), Integer.parseInt(split[12]));
          citizen.setAddress(address);
          List&lt;Education&gt; educations = new ArrayList&lt;&gt;();
          // to do...
          citizen.set_educations(educations);
          List&lt;SocialInsuranceRecord&gt; socilInsuranceRecords = new ArrayList&lt;&gt;();
          // to do...
          citizen.set_socialInsuranceRecords(socilInsenter code hereuranceRecords);
          return citizen;
      }
  }
  </code></pre>