Getting data from csv file and returning objects in collections

Posted by Jacob on Programmers See other posts from Programmers or by Jacob
Published on 2014-05-28T17:39:19Z Indexed on 2014/05/28 22:01 UTC
Read the original article Hit count: 214

Filed under:

I have very simple class of person as below:

public class Person {

    int ID;
    Gender gender;
    Date dateOfBirth;

    public Person(final int iD, final Gender gender,final Date dateOfBirth) {
        ID = iD;
        this.gender = gender;
        this.dateOfBirth = dateOfBirth;
    }
}

Gender is enum :

public enum Gender {
    Male, Female
}

In CSV file i will have data, for example:

1;Male;23-02-2001
2;Female;11-06-1989
3;Male;02-12-1999

Is in java any simple way to get all persons from csv file and return it as ArrayList<Person> persons ?

© Programmers or respective owner

Related posts about java