CSVFormat csvFormat = CSVFormat.newFormat(',').withIgnoreEmptyLines().withFirstRecordAsHeader();
CSVParser parser = null;
BufferedReader reader = null;
try {
reader = Files.newBufferedReader(file.toPath(), StandardCharsets.ISO_8859_1);
parser = new CSVParser(reader, csvFormat);
for (CSVRecord record : parser) {
try {
// Copy records to your bean
} catch (Exception e) {
System.out.println("Error in parsing" + e);
}
}
} catch (Exception x) {
System.out.println("Error");
}
|