user1191027
user1191027

Reputation:

Parse from a CSV String instead of a File

I know that when you want to parse a CSV file you use:

CSVReader reader = new CSVReader(new FileReader(csvPath));

But what about when you have a String csv; and you want to parse from that instead?

Upvotes: 15

Views: 12807

Answers (2)

Reimeus
Reimeus

Reputation: 159754

You can use the same constructor:

CSVReader reader = new CSVReader(new StringReader("one,two,three"));

Upvotes: 22

user1907906
user1907906

Reputation:

Use a StringReader to read from a String.

Upvotes: 2

Related Questions