Using OpenCSV to parse UTF-8 documents without BOM results in the first column not read. Giving as an input the same document content but encoded in UTF-8 with BOM works correctly.
I set specifically the charset to UTF-8
fileInputStream = new FileInputStream(file);
inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
reader = new BufferedReader(inputStreamReader);
HeaderColumnNameMappingStrategy<Bean> ms = new HeaderColumnNameMappingStrategy<Bean>();
ms.setType(Bean.class);
CsvToBean<Bean> csvToBean = new CsvToBeanBuilder<Bean>(reader).withType(Bean.class).withMappingStrategy(ms)
.withSeparator(';').build();
csvToBean.parse();
I've created a sample project where the issue can be reproduced: https://github.com/dajoropo/csv2beanSample
Running the Unit Test you can see how the UTF-8 file without BOM fails and with BOM works correctly.
The error comes in the second assertion, because the first column in not read. Result it:
[Bean [a=null, b=second, c=third]]
Any hint?