Nick Welki
Nick Welki

Reputation: 455

Importing a CSV File into Java

In the program I am writing, I want to be able to import CSV files. At the moment, it takes a basic text file in.

File mainemails = new File ("mainemails.txt");

I know that for CSV imports using File is probably not the most time-efficient thing to use. What would be the most efficient way to import a CSV file? Would I have to download any new libraries to use an efficient method?

Upvotes: 8

Views: 14168

Answers (2)

Jayan
Jayan

Reputation: 18459

You can use opencsv for importing csv data and then constructing objects from it.

I prefer using libraries so that I can save development time. Also they tend to solve specific problems better.

Upvotes: 13

darrengorman
darrengorman

Reputation: 13116

Try OpenCSV as suggested here and here.

Upvotes: 5

Related Questions