for years I've been parsing csv files during my nightly batch jobs using the following logic without issue. Anyhow I'm doing a full rewrite of the application and I'm now wondering if there may be any performance / quality gains in using something like opencsv? I have no experience with other libraries, so I was hoping someone else with experience could chime in.
while ((line = br.readLine()) != null) {
String[] items = line.split(",");
for (int i = 0; i < items.length; ++i) {
// Remove extra quote
if (items[i].length > 2) {
items[i] = items[i].replaceAll("\"", "");
}
// Replace blank items with nulls
if (items[i].matches("^\\s*$")) {
items[i] = null;
}
}
String item0 = item[0];
String item1 = item[1];
}