Hi there,
A thread was started earlier about splitting up a String using the split() method of the string class. Reading that did help me quite a lot in solving a problem of mine that is VERY similiar.
Say I have this in a txt file:
"Dean Grobler 0794400541 NA NA dean3446@gmail.com
Avril Gibson 0825426532 NA NA avril@gmail.com
Peter Pumpkineater 0724128945 0119548714 peter@webmail.com"
and I have this class:
public class Contact
{
String name,
surname,
mobile,
home
work
email;
public Contact(String name, String surname, String mobile, String home,
String work, String email)
{
this.name = name;
this.surname = surname;
this.mobile = mobile;
this.home = home;
this.work = work;
this.email = email;
}
/*.
.
.getters and setters etc.
*/
}
How would I continue reading line by line in the file (regardless of how many lines of information there is in the .txt) and keep on popping out 'Contact objects'? So then in the above .txt example it would create 3 Contact objects?