I have the below block of code which uses OpenCSV to read a CSV file and store the 7th column. The problem I face is that I use ;
as delimiter in the CSV file but it takes ,
as delimiter as well. How can I avoid this?
Putting "" in CSV is not possible, since we get a non-editable file from client.
CSVReader reader = null;
String[] nextCsvLine = new String[50];
String splitBy = ";";
int count = 0;
try {
StringReader sr = new StringReader(new String(in, offset, len));
reader = new CSVReader(sr);
while ((nextCsvLine = reader.readNext()) != null) {
for (String linewithsemicolon : nextCsvLine) {
log.debug("Line read : "+linewithsemicolon);
String[] b = linewithsemicolon.split(splitBy);
if (count==0){
count++;
continue;
}
else {
detailItems.add(b[7]);
log.debug("7th position: "+b[7]);
count++;
}
}