Load a CSV file into an ArrayList

(Recovered from my old Blog).

It isn’t hard to write code which iterates through files, cuts them up and loads them into an ArrayList. And if the delimiting character isn’t a comma? No problem, it isn’t hard to add that functionality. And if you want to skip the first set of lines because you’re paginating the file? Easy! And if you want to write some changes back out again – no problem, I can add that feature in no time.

Except it’s already been done. So why waste the time? 🙂

OpenCSV is an easy to use library which you can embed into your applications (Apache License). Then you can simply do something like:

And you’re done. See the OpenCSV homepage for some of the other features.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: