Import java.io.FileNotFoundException;
Import Java.io.FileReader;
Import java.io.IOException;
Import Org.apache.commons.csv.CSVFormat;
Import Org.apache.commons.csv.CSVParser;
Import Org.apache.commons.csv.CSVRecord;
public class Readcvs {
/**
* @param args
*
/public static void main (string[] args) throws Filenotfoundexc Eption, ioexception{
/TODO auto-generated method stub
Csvparser parser = new Csvparser (New FileReader (" Test.cvs "),
CSVFormat.DEFAULT.withHeader ());
for (Csvrecord record:parser) {
System.out.printf ("%s\t%s\n",
record.get ("COL1"),
record.get ("COL2 "));
}
Parser.close ();
}
Original: http://www.javacodegeeks.com/2013/10/how-to-read-csv-files-in-java-a-case-study-of-iterator-and-decorator.html
Download nightly BUiD jar:https://repository.apache.org/content/groups/snapshots/org/apache/commons/commons-csv/1.0-snapshot/
Source code: http://pan.baidu.com/share/link?shareid=3161611855&uk=3878681452