[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1. Start Using Quickly

To use SimpleCSV you need to do the following steps. For more information, see section Using SimpleCSV.

  1. Download SimpleCSV from the SimpleCSV release page. See section Downloading Jar.
  2. 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;
        }
    
  3. Create a CsvProcessor utility class for the entity.
     
    CsvProcessor<Account> processor =
        new CsvProcessor<Account>(Account.class);
    
  4. Write a collection of Account entities to disk in CSV format.
     
    processor.writeAll(new File("accounts.csv"),
        accounts, true /* write header */); 
    
  5. Read in from a CSV file and get a collection of Accounts:
     
    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.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Gray Watson on February 15, 2019 using texi2html 1.82.