java de lecture de fichier csv et stocker ses informations dans ArrayList<class>

Je suis un java débutant et j'ai besoin d'un peu d'aide

voici donc ma méthode principale:

RegistrationMethods dmv = new RegistrationMethods();
ArrayList<CarOwner> ItState = new ArrayList<CarOwner>();
dmv.processTextToArrayList(ItState);

et j'ai une classe appelée CarOwner et il a getters et setters pour firstName, lastName, license, month, year variables d'instance.

Et c'est ma méthode d'en-tête pour processTextToArrayList méthode:

public void processTextToArrayList(ArrayList<CarOwner> inList) throws IOException

cette méthode est censée ajouter de nouveaux CarOwner objets à la inList CarOwner de la collection passée. Pour chaque ligne du fichier csv, un CarOwner objet est ajouté à inList.

J'ai à lire à partir de fichier csv dans arraylist
mon fichier csv contient quelque chose comme:

Bunny Bugs ACB-123 5 2013

Bunny Honey DEF-456 9 2013

Bunny Lola GHI-789 3 2014

comment ce code à l'aide de la boucle while?

edit:

mon CarOwner classe est :

public class CarOwner extends Citizen implements CarOwnerInterface, Serializable
{
private String license;
private int month, year;
public CarOwner()
{
super();
license = "Not Assigned";
month = 0;
year = 0;        
}
public CarOwner(String inFirst, String inLast, String inLicense, int inMonth, int inYear)
{
super(inFirst, inLast);
license = inLicense;
month = inMonth;
year = inYear;
}
public void setLicense(String inLicense)
{
license = inLicense;
}
public String getLicense()
{
return license;
}
public void setMonth(int inMonth)
{
month = inMonth;
}
public int getMonth()
{
return month;
}
public void setYear(int inYear)
{
year = inYear;
}
public int getYear()
{
return year;
}
public int compareTo(Object o)
{
if ((o != null ) && (o instanceof CarOwner))
{
CarOwner otherOwner = (CarOwner) o;
if (otherOwner.compareTo(getYear()) > 0)
return -1;
else if (otherOwner.compareTo(getYear()) < 0)
return 1;
else if (otherOwner.equals(getYear()))
if (otherOwner.compareTo(getMonth()) > 0)
return -1;
else if (otherOwner.compareTo(getMonth()) < 0)
return 1;
else if (otherOwner.equals(getMonth()))
return 0;
}
return -1;
}

}

et mon Citoyen de la classe, c'est aussi:

public class Citizen implements CitizenInterface, Serializable
{
private String firstName, lastName;
public Citizen()
{
firstName = "No Name";
lastName = "No Name";
}
public Citizen(String inFirstName, String inLastName)
{
firstName = inFirstName;
lastName = inLastName;
}
public void setFirstName(String inFirst)
{
firstName = inFirst;
}
public String getFirstName()
{
return firstName;
}
public void setLastName(String inLast)
{
lastName = inLast;
}
public String getLastName()
{
return lastName;
}
public String toString()
{
String str;
str = firstName + " " + lastName;
return str;
}
Veuillez faire une tentative pour nous montrer la CarOwner classe. Et merci de développer processTextToArrayList. Il doit avoir quelque chose là-bas qui se lit à partir d'un fichier. Jetez un oeil à stackoverflow.com/questions/224952/....

OriginalL'auteur cohsta | 2014-12-05