I am trying to parse a CSV file with some @Parsed
annotation in a form file but it's not working.
I am using univocity
lib
Init.java
public static void main(String[] args) throws FileNotFoundException {
CsvParserSettings parserSettings = new CsvParserSettings();
BeanListProcessor<FireReportFormGeneral> rowProcessor = new BeanListProcessor<FireReportFormGeneral>(FireReportFormGeneral.class);
parserSettings.setRowProcessor(rowProcessor);
parserSettings.setHeaderExtractionEnabled(true);
CsvParser parser = new CsvParser(parserSettings);
parser.parse(new FileReader("/home/jose/Desktop/example.csv"));
List<FireReportFormGeneral> beans = rowProcessor.getBeans();
System.out.println(rowProcessor.getHeaders());
System.out.println(beans);
}
FireReportFormGeneral.java
@Parsed(field = "Account Number")
private String accountNumber;
@Parsed(field = "Account Type")
private String accountType;
@Parsed(field = "Bank Client Identification Number")
private String bankClientIdNumber;
@Parsed(field = "Account Opening Date")
private String accountOpeningDate;
//getters and setters
But my output is always something like:
[Ljava.lang.String;@7591083d [com.opessoftware.fire.csv.reader.FireReportFormGeneral@77a567e1, com.opessoftware.fire.csv.reader.FireReportFormGeneral@736e9adb]
For sure I am doing something wrong but I could not find the answer.
Thanks.
EDIT:
I solve the problem
The thing is if a call beans.get(index).getAccountName()
for example it's going to return values for me.