I have the following java class:
public class Persona {
private string employee_name;
private String user_id;
private String domain;
private String email;
private String role;
@ Override
public String toString () {
return "Person [employee_name=" + employee_name + ", user_id=" + user_id + ", domain=" + domain + ", email="
+ email + ", role=" + role + "]";
}
// Gets and Sets omitted to stay smaller
}
The following CSV file:
employee_name, user_id, email domain, scroll
BurtonMStephenson, BMS0001, dtaa.com, Burton.M.Stephenson @ dtaa.com, Security
Keelie M Goodwin, KMG0002, dtaa.com, Keelie.M.Goodwin @ dtaa.com, Engineer
Dara El Craig, DOC0003, dtaa.com, Dara.O.Craig @ dtaa.com, VP
I have the class responsible for reading the CSV file and playing in opbetos of the person type:
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import com.opencsv.bean.CsvToBean;
import com.opencsv.bean.CsvToBeanBuilder;
public class LeerLinhasOpenCsv {
public static void main (String[] args) throws IOException {
// TODO Auto-generated method stub
Reader Reader = Files.newBufferedReader (Paths.get ("LDAP_head.csv"));
CsvToBean csvToBean = new CsvToBeanBuilder (reader)
.withType (Pessoa.class) .build ();
list people = csvToBean.parse ();
(Person: person)
System.out.println (pessoa.toString ());
}
}
But when I do the printing, everything "Null" appears
person [employee_name=null, user_id=null, domain=null, email=null, role=null]
person [employee_name=null, user_id=null, domain=null, email=null, role=null]
person [employee_name=null, user_id=null, domain=null, email=null, role=null]
person [employee_name=null, user_id=null, domain=null, email=null, role=null]
person [employee_name=null, user_id=null, domain=null, email=null, role=null]