Hello, there seems to be an issue with the CsvToBean when constructed with a CsvToBeanBuilder.
The setup is the following. A CsvToBean object is constructed by a CsvToBeanBuilder.
return new CsvToBeanBuilder<C>(targetReader)
.withType(cls)
.withSkipLines(skipHeader)
.withSeparator(';')
.withQuoteChar('"')
.withErrorLocale(Locale.ENGLISH)
.build()
.parse();
where targetReader is a StringReader constructed with the file as a string in UTF-8 format.
The constructed bean contains fields that are annotated with a @CsvCustomBindByPosition referencing a custom converter. The custom converter extends the AbstractBeanField, overriding the convert method.
...
@Override
protected Object convert(String value)
throws CsvDataTypeMismatchException, CsvConstraintViolationException {
...
}
An example line written for tests might be:
1; " 0 " ; " 0"; 999
Here the converters convert method is passed the strings "0 "" for the first and "0" for the second quoted field. It seems like for the first field the first quote is successfully detected and accounted for by the CsvToBean's parse method, the second is not. For the second field both quotes are detected
First off download the latest code and build with it and see if the fix I merged in from Piotr for https://sourceforge.net/p/opencsv/bugs/257/ fixes the issue. Otherwise could you please supply a unit test similar to what is in bug #257 that proves the issue and allows me to quickly try different configurations to see if there is a easy fix/workaround. A good unit test also prevents me from going off in the wrong direction if I accidentally misinterpret something.