1. Start Using Quickly
To use SimpleCSV you need to do the following steps. For more information, see section Using SimpleCSV.
- Download SimpleCSV from the SimpleCSV release page. See section Downloading Jar.
- Add
@CsvColumn
annotation to each of the fields or get/set method that you want to write and read to/from
CSV files. See section CsvColumn Annotation.
| public class Account {
…
@CsvColumn
private String name;
|
Or.
| public class Account {
…
@CsvColumn
private String getName() {
return name;
}
@CsvColumn
private void setName(String name) {
this.name = name;
}
|
- Create a CsvProcessor utility class for the entity.
| CsvProcessor<Account> processor =
new CsvProcessor<Account>(Account.class);
|
- Write a collection of
Account
entities to disk in CSV format.
| processor.writeAll(new File("accounts.csv"),
accounts, true /* write header */);
|
- Read in from a CSV file and get a collection of
Account
s:
| List<Account> accounts =
processor.readAll(new File("accounts.csv"),
true /* first line header */,
true /* validate header */,
null /* used to record parse errors */);
|
For more extensive instructions, see section Using SimpleCSV.
This document was generated by Gray Watson on February 15, 2019 using texi2html 1.82.